Compare commits

...

2 commits

Author SHA1 Message Date
40aa61ba98
constrain traces to the screen 2025-04-07 17:54:47 -04:00
e0d468e15f
change defaults 2025-04-07 17:30:05 -04:00

17
main.c
View file

@ -142,9 +142,9 @@ int main(void) {
IntMasterEnable(); IntMasterEnable();
uint8_t voltage_scale = 0; uint8_t voltage_scale = 4; // 2v
uint8_t time_scale = 0; uint8_t time_scale = 5; // 20us
uint8_t trigger_mode = 1; uint8_t trigger_mode = 1; // rising
while (true) { while (true) {
// calculate cpu usage // calculate cpu usage
@ -238,9 +238,12 @@ int main(void) {
float fVoltsPerDiv = gVoltageScale[voltage_scale]; float fVoltsPerDiv = gVoltageScale[voltage_scale];
float fScale = (VIN_RANGE * PIXELS_PER_DIV)/((1 << ADC_BITS) * fVoltsPerDiv); float fScale = (VIN_RANGE * PIXELS_PER_DIV)/((1 << ADC_BITS) * fVoltsPerDiv);
GrContextForegroundSet(&sContext, ClrPink); GrContextForegroundSet(&sContext, ClrYellow);
for(j=0; j<LOCAL_BUF_LEN; j++) { for(j=0; j<LOCAL_BUF_LEN; j++) {
#define TRANSPOSE(x) (HEIGHT/2) - (int)roundf(fScale * ((int)x - ADC_OFFSET)); #define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define CONSTRAIN(x) MAX(MIN(HEIGHT - 1, x), 0)
#define TRANSPOSE(x) CONSTRAIN((HEIGHT/2) - (int)roundf(fScale * ((int)x - ADC_OFFSET)))
uint32_t upper,lower, current, last; uint32_t upper,lower, current, last;
if (j==0) { if (j==0) {
@ -250,10 +253,6 @@ int main(void) {
} else { } else {
current = TRANSPOSE(local_adc_buffer[j]); current = TRANSPOSE(local_adc_buffer[j]);
// couldn't find these anywhere
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
upper = MAX(current, last); upper = MAX(current, last);
lower = MIN(current, last); lower = MIN(current, last);