constrain traces to the screen

This commit is contained in:
Andy Killorin 2025-04-07 17:54:47 -04:00
parent e0d468e15f
commit 40aa61ba98
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

11
main.c
View file

@ -238,9 +238,12 @@ int main(void) {
float fVoltsPerDiv = gVoltageScale[voltage_scale];
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++) {
#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;
if (j==0) {
@ -250,10 +253,6 @@ int main(void) {
} else {
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);
lower = MIN(current, last);