constrain traces to the screen
This commit is contained in:
parent
e0d468e15f
commit
40aa61ba98
1 changed files with 5 additions and 6 deletions
11
main.c
11
main.c
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue