add trigger disable
This commit is contained in:
parent
67814ef2ce
commit
2779d26b2a
1 changed files with 20 additions and 8 deletions
28
main.c
28
main.c
|
@ -144,7 +144,7 @@ int main(void) {
|
|||
|
||||
uint8_t voltage_scale = 0;
|
||||
uint8_t time_scale = 0;
|
||||
uint8_t rising = 1;
|
||||
uint8_t trigger_mode = 1;
|
||||
|
||||
while (true) {
|
||||
// calculate cpu usage
|
||||
|
@ -158,7 +158,8 @@ int main(void) {
|
|||
while (fifo_get(&button)) {
|
||||
switch (button) {
|
||||
case S1: // toggle edge
|
||||
rising = !rising;
|
||||
trigger_mode++;
|
||||
trigger_mode %= 3;
|
||||
break;
|
||||
case S2: // draw
|
||||
refresh = !refresh;
|
||||
|
@ -203,10 +204,16 @@ int main(void) {
|
|||
snprintf(str, sizeof(str), "CPU Load %.1f%%", usage_percent);
|
||||
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ HEIGHT - 10, /*opaque*/ false);
|
||||
|
||||
if (rising) {
|
||||
GrStringDraw(&sContext, "^", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||
} else {
|
||||
GrStringDraw(&sContext, "v", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||
switch (trigger_mode) {
|
||||
case 1:
|
||||
GrStringDraw(&sContext, "^", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||
break;
|
||||
case 0:
|
||||
GrStringDraw(&sContext, "v", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||
break;
|
||||
case 2:
|
||||
GrStringDraw(&sContext, "-", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||
break;
|
||||
}
|
||||
|
||||
// display graph
|
||||
|
@ -215,7 +222,12 @@ int main(void) {
|
|||
int32_t adc_current_index;
|
||||
int32_t j;
|
||||
if (refresh) {
|
||||
int trigger = Trigger(rising);
|
||||
int trigger;
|
||||
if (trigger_mode == 2) {
|
||||
trigger = gADCBufferIndex - (WIDTH / 2); // show latest if trigger disabled
|
||||
} else {
|
||||
trigger = Trigger(trigger_mode);
|
||||
}
|
||||
|
||||
adc_current_index = trigger - (WIDTH / 2);
|
||||
for (j=0; j<LOCAL_BUF_LEN; j++) {
|
||||
|
@ -303,6 +315,6 @@ int Trigger(bool rising) // search for edge trigger
|
|||
}
|
||||
}
|
||||
if (x == x_stop) // for loop ran to the end
|
||||
x = x = gADCBufferIndex - (WIDTH / 2); // reset x back to how it was initialized
|
||||
x = gADCBufferIndex - (WIDTH / 2); // reset x back to how it was initialized
|
||||
return x;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue