7
mirror of https://github.com/EEVengers/ThunderScope.git synced 2025-04-22 17:43:44 +00:00

UI->Plumber: SetVerticalScaling

This commit is contained in:
Ratan Varghese 2021-03-25 12:15:16 -04:00
parent 9bb950af94
commit 16fad163d9
4 changed files with 50 additions and 2 deletions
Software/waveview
README_protocol.md
scope_link/src
src
components/sidebar/widgets
util

View File

@ -89,7 +89,7 @@ Cmd | DataSize | Name | Description
0x03 | 2 (useless) | GetData3 | Reserved, If we need 1 command/ch
0x04 | 2 (useless) | GetData4 | Reserved, If we need 1 command/ch
0x36 | 2? | SetBandwidth |
0x37 | 2? | SetVerticalScaling |
0x37 | 4 | SetVerticalScaling | Data has ch, mV/div as int16
0x38 | 2 | SetVerticalOffset | Data\[0\] has offset
0x39 | 2? | SetHorizontalOffset |
0x3A | 2 | SetCoupling | Data\[0\] has 0\1 for AC\DC

View File

@ -371,6 +371,32 @@ void controller::controllerLoop()
controllerQueue_tx.push(tempPacket);
}
break;
case CMD_SetVerticalScaling: {
INFO << "Packet command: SetVerticalScaling";
const int packetSize = 4;
if(currentPacket->dataSize != packetSize) {
ERROR << "Unexpected size for SetVerticalScaling packet";
}
else {
int16_t* data16 = (int16_t*) currentPacket->data;
int ch = data16[0];
int millivoltPerDiv = data16[1];
if(ch < 1 || ch > 4) {
ERROR << "Bad channel for SetVerticalScaling";
}
if(millivoltPerDiv < 0 || millivoltPerDiv > 10000) {
ERROR << "Bad millivoltPerDiv for SetVerticalScaling";
}
//Do something...
}
EVPacket* tempPacket = (EVPacket*) malloc(sizeof(EVPacket));
tempPacket->data = NULL;
tempPacket->dataSize = 0;
tempPacket->packetID = 0;
tempPacket->command = CMD_SetEdgeType;
controllerQueue_tx.push(tempPacket);
}
break;
case CMD_SetMath: {
INFO << "Packet command: SetMath";
const int packetSize = 4;

View File

@ -18,10 +18,16 @@ class VerticalWidget extends React.Component<any, any> {
// Time Per Division
incrementTimePerDivision = () => {
let v = this.props.verticalWidget;
let idx = v.timePerDivision[v.activeChannel-1].index - 1;
Plumber.getInstance().handleVert(v.activeChannel, idx);
this.props.dispatch({type: 'vertical/increaseTimePerDivision'});
}
decrementTimePerDivision = () => {
let v = this.props.verticalWidget;
let idx = v.timePerDivision[v.activeChannel-1].index + 1;
Plumber.getInstance().handleVert(v.activeChannel, idx);
this.props.dispatch({type: 'vertical/decreaseTimePerDivision'});
}

View File

@ -2,8 +2,9 @@ import CMD from '../configuration/enums/cmd';
import { SetChState } from './setChHelper';
import MathOperators from '../configuration/enums/mathOperators';
import DefaultValues from '../configuration/defaultValues';
import { convertTime } from './convert';
import { convertTime, convertVoltage } from './convert';
import TimeUnit from '../configuration/enums/timeUnit';
import VoltageUnit from '../configuration/enums/voltageUnit';
export enum SetMathOp {
SetMath_None = 0,
@ -162,6 +163,21 @@ export class Plumber {
this.cycle(setWinArgs);
}
public handleVert(ch: number, idx: number) {
let bases = DefaultValues.x1ProbeValues;
let targIdx = (idx < 0) ? 0 : ((idx >= bases.length) ? bases.length : idx);
let targ = bases[targIdx];
let targMillivolt = convertVoltage(targ.value, targ.unit, VoltageUnit.MilliVolt);
let args = {
headCheck: () => true,
bodyCheck: () => true,
cmd: CMD.CMD_SetVerticalScaling,
id: 0,
writeData: new Int8Array((new Int16Array([ch,targMillivolt])).buffer)
}
this.cycle(args);
}
public decodeGetMinMax(args: PlumberArgs, a: Int8Array) {
let maxCh = 4;
let a64u = new BigUint64Array(a.buffer);