Features/bottombar redux #97

Merged
A-Nilfgaardian merged 7 commits from features/bottombar-redux into master 2021-01-20 14:34:28 +00:00
6 changed files with 122 additions and 37 deletions
Showing only changes of commit ccb21acfa9 - Show all commits

View File

@ -32,7 +32,7 @@ class HorizontalWidget extends React.Component<any, any> {
<div className="HorizontalWidgetAdjustBlock-HorizontalTimeBase"> <div className="HorizontalWidgetAdjustBlock-HorizontalTimeBase">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementTimeBase}> onClick={() => this.decrementTimeBase()}>
- -
</button> </button>
<label <label
@ -43,7 +43,7 @@ class HorizontalWidget extends React.Component<any, any> {
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementTimeBase}> onClick={() => this.incrementTimeBase()}>
+ +
</button> </button>
</div> </div>
@ -51,7 +51,7 @@ class HorizontalWidget extends React.Component<any, any> {
<div className="HorizontalWidgetAdjustBlock-HorizontalOffset"> <div className="HorizontalWidgetAdjustBlock-HorizontalOffset">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementOffset}> onClick={() => this.decrementOffset()}>
- -
</button> </button>
<label <label
@ -62,7 +62,7 @@ class HorizontalWidget extends React.Component<any, any> {
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementOffset}> onClick={() => this.incrementOffset()}>
+ +
</button> </button>
</div> </div>

View File

@ -41,7 +41,7 @@ class VerticalWidget extends React.Component<any, any> {
<div className="VerticalWidgetAdjustChannelBlock"> <div className="VerticalWidgetAdjustChannelBlock">
<button <button
className="MinusButton" className="MinusButton"
onClick={this.decreaseChannel}> onClick={() => this.decreaseChannel()}>
- -
</button> </button>
<label <label
@ -52,7 +52,7 @@ class VerticalWidget extends React.Component<any, any> {
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={this.increaseChannel}> onClick={() => this.increaseChannel()}>
+ +
</button> </button>
</div> </div>
@ -60,7 +60,7 @@ class VerticalWidget extends React.Component<any, any> {
<div className="VerticalWidgetAdjustBlock-TimePerDivision"> <div className="VerticalWidgetAdjustBlock-TimePerDivision">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementTimePerDivision}> onClick={() => this.decrementTimePerDivision()}>
- -
</button> </button>
<label <label
@ -71,7 +71,7 @@ class VerticalWidget extends React.Component<any, any> {
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementTimePerDivision}> onClick={() => this.incrementTimePerDivision()}>
+ +
</button> </button>
</div> </div>
@ -79,7 +79,7 @@ class VerticalWidget extends React.Component<any, any> {
<div className="VerticalWidgetAdjustBlock-VerticalOffset"> <div className="VerticalWidgetAdjustBlock-VerticalOffset">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementVerticalOffset}> onClick={() => this.decrementVerticalOffset()}>
- -
</button> </button>
<label <label
@ -90,7 +90,7 @@ class VerticalWidget extends React.Component<any, any> {
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementVerticalOffset}> onClick={() => this.incrementVerticalOffset()}>
+ +
</button> </button>
</div> </div>

View File

@ -31,7 +31,44 @@ const x10ProbeValues = [
// 13 different voltages per divison presets // 13 different voltages per divison presets
// Start at x1ProbeValues[6] and change accordingly // Start at x1ProbeValues[6] and change accordingly
const horizontalTimeBases = [
"1ns/div",
"2ns/div",
"5ns/div",
"10ns/div",
"20ns/div",
"50ns/div",
"100ns/div",
"200ns/div",
"500ns/div",
"1us/div",
"2us/div",
"5us/div",
"10us/div",
"20us/div",
"50us/div",
"100us/div",
"200us/div",
"500us/div",
"1ms/div",
"2ms/div",
"5ms/div",
"10ms/div",
"20ms/div",
"50ms/div",
"100ms/div",
"200ms/div",
"500ms/div",
"1s/div",
"2s/div",
"5s/div",
"10s/div"
];
// 31 different voltages per division presets
// Start at horizontalTimeBases[15] and change accordingly
export default { export default {
x1ProbeValues, x1ProbeValues,
x10ProbeValues x10ProbeValues,
horizontalTimeBases
}; };

View File

@ -0,0 +1,8 @@
enum DefaultChannelColor {
Channel1 = "#EBFF00",
Channel2 = "#00FF19",
Channel3 = "#0075FF",
Channel4 = "#FF0000"
};
export default DefaultChannelColor;

View File

@ -1,40 +1,54 @@
import DefaultValues from '../../configuration/defaultValues';
const initialState = { const initialState = {
horizontalTimeBase: {value: 0, unit: "ns/div"}, horizontalTimeBase: {
horizontalOffset: {value: 0, unit: "ms"} value: DefaultValues.horizontalTimeBases[15],
index: 15
},
horizontalOffset: {
value: 0,
unit: "ms"
}
}; };
export default function(state = initialState, action: {type: any, payload: any}) { export default function(state = initialState, action: {type: any, payload: any}) {
switch(action.type) { switch(action.type) {
case "horizontal/increaseTimeBase": case "horizontal/increaseTimeBase":
if (state.horizontalTimeBase.index >= 30) {
return { ...state };
}
return { return {
...state, ...state,
horizontalTimeBase: { horizontalTimeBase: {
value: state.horizontalTimeBase.value + 1, value: DefaultValues.horizontalTimeBases[state.horizontalTimeBase.index + 1],
unit: state.horizontalTimeBase.unit index: state.horizontalTimeBase.index + 1
} }
} }
case "horizontal/decreaseTimeBase": case "horizontal/decreaseTimeBase":
if (state.horizontalTimeBase.index === 0) {
return { ...state };
}
return { return {
...state, ...state,
horizontalTimeBase: { horizontalTimeBase: {
value: state.horizontalTimeBase.value - 1, value: DefaultValues.horizontalTimeBases[state.horizontalTimeBase.index - 1],
unit: state.horizontalTimeBase.unit index: state.horizontalTimeBase.index - 1
} }
} }
case "horizontal/increaseOffset": case "horizontal/increaseOffset":
return { return {
...state, ...state,
horizontalOffset: { horizontalOffset: {
value: state.horizontalOffset.value + 1, ...state.horizontalOffset,
unit: state.horizontalOffset.unit value: state.horizontalOffset.value + 1
} }
} }
case "horizontal/decreaseOffset": case "horizontal/decreaseOffset":
return { return {
...state, ...state,
horizontalOffset: { horizontalOffset: {
value: state.horizontalOffset.value - 1, ...state.horizontalOffset,
unit: state.horizontalOffset.unit value: state.horizontalOffset.value - 1
} }
} }
default: default:

View File

@ -1,13 +1,14 @@
import DefaultValues from '../../configuration/defaultValues'; import DefaultValues from '../../configuration/defaultValues';
import DefaultChannelColor from '../../configuration/enums/defaultChannelColor';
import MeasurementType from '../../configuration/enums/measurementType'; import MeasurementType from '../../configuration/enums/measurementType';
const initialState = { const initialState = {
activeChannel: 1, activeChannel: 1,
channelColorsList: [ channelColorsList: [
"#EBFF00", DefaultChannelColor.Channel1,
"#00FF19", DefaultChannelColor.Channel2,
"#0075FF", DefaultChannelColor.Channel3,
"#FF0000" DefaultChannelColor.Channel4
], ],
timePerDivision: [ timePerDivision: [
{value: DefaultValues.x1ProbeValues[6], index: 6}, {value: DefaultValues.x1ProbeValues[6], index: 6},
@ -30,6 +31,9 @@ const initialState = {
}; };
export default function(state = initialState, action: {type: any, payload: any}) { export default function(state = initialState, action: {type: any, payload: any}) {
var channelIndex = state.activeChannel - 1;
var tmp;
switch(action.type) { switch(action.type) {
case "vertical/increaseChannel": case "vertical/increaseChannel":
if (state.activeChannel >= 4) { if (state.activeChannel >= 4) {
@ -48,23 +52,45 @@ export default function(state = initialState, action: {type: any, payload: any})
activeChannel: state.activeChannel - 1 activeChannel: state.activeChannel - 1
}; };
case "vertical/increaseVerticalOffset": case "vertical/increaseVerticalOffset":
return { ...state } tmp = state.verticalOffset;
// Decrease vertical offset
tmp[channelIndex].value = state.verticalOffset[channelIndex].value + 1;
return {
...state,
verticalOffset: tmp
}
case "vertical/decreaseVerticalOffset": case "vertical/decreaseVerticalOffset":
return { ...state } tmp = state.verticalOffset;
// Decrease vertical offset
tmp[channelIndex].value = state.verticalOffset[channelIndex].value - 1;
return {
...state,
verticalOffset: tmp
}
case "vertical/increaseTimePerDivision": case "vertical/increaseTimePerDivision":
if (state.timePerDivision[state.activeChannel - 1].index >= 12) {
return { ...state }
};
break;
// Increase time per division
case "vertical/decreaseTimePerDivision":
if (state.timePerDivision[state.activeChannel - 1].index === 0) { if (state.timePerDivision[state.activeChannel - 1].index === 0) {
return { ...state } return { ...state }
}; };
// Decrease time per division tmp = state.timePerDivision;
break;
tmp[channelIndex].index = state.timePerDivision[channelIndex].index - 1;
tmp[channelIndex].value = DefaultValues.x1ProbeValues[tmp[channelIndex].index];
return {
...state,
timePerDivision: tmp
}
case "vertical/decreaseTimePerDivision":
if (state.timePerDivision[state.activeChannel - 1].index >= 12) {
return { ...state }
};
tmp = state.timePerDivision;
tmp[channelIndex].index = state.timePerDivision[channelIndex].index + 1;
tmp[channelIndex].value = DefaultValues.x1ProbeValues[tmp[channelIndex].index];
return {
...state,
timePerDivision: tmp
}
default: default:
return state; return state;
} }