implemented graphics
This commit is contained in:
parent
6004eaac27
commit
564d05b183
1 changed files with 73 additions and 0 deletions
73
main.c
73
main.c
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
uint32_t gSystemClock = 120000000; // [Hz] system clock frequency
|
uint32_t gSystemClock = 120000000; // [Hz] system clock frequency
|
||||||
|
|
||||||
|
tContext sContext;
|
||||||
|
|
||||||
#define LOCAL_BUF_LEN 128
|
#define LOCAL_BUF_LEN 128
|
||||||
uint16_t adc_buffer_sample[LOCAL_BUF_LEN]; // copy of g adc buffer
|
uint16_t adc_buffer_sample[LOCAL_BUF_LEN]; // copy of g adc buffer
|
||||||
uint8_t adc_buffer_processed[LOCAL_BUF_LEN]; // copy of g adc buffer
|
uint8_t adc_buffer_processed[LOCAL_BUF_LEN]; // copy of g adc buffer
|
||||||
|
@ -109,6 +111,12 @@ int main(void)
|
||||||
start_signal();
|
start_signal();
|
||||||
start_sampler();
|
start_sampler();
|
||||||
|
|
||||||
|
Crystalfontz128x128_Init(); // Initialize the LCD display driver
|
||||||
|
Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); // set screen orientation
|
||||||
|
|
||||||
|
GrContextInit(&sContext, &g_sCrystalfontz128x128); // Initialize the grlib graphics context
|
||||||
|
GrContextFontSet(&sContext, &g_sFontFixed6x8); // select font
|
||||||
|
|
||||||
/* Start BIOS */
|
/* Start BIOS */
|
||||||
BIOS_start();
|
BIOS_start();
|
||||||
|
|
||||||
|
@ -171,8 +179,73 @@ void process_waveform(UArg arg1, UArg arg2) {
|
||||||
|
|
||||||
void display_waveform(UArg arg1, UArg arg2)
|
void display_waveform(UArg arg1, UArg arg2)
|
||||||
{
|
{
|
||||||
|
char str[50]; // string buffer
|
||||||
|
tRectangle rectFullScreen = {0, 0, GrContextDpyWidthGet(&sContext)-1, GrContextDpyHeightGet(&sContext)-1};
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
Semaphore_pend(display_sem, BIOS_WAIT_FOREVER);
|
Semaphore_pend(display_sem, BIOS_WAIT_FOREVER);
|
||||||
|
|
||||||
|
GrContextForegroundSet(&sContext, ClrBlack);
|
||||||
|
GrRectFill(&sContext, &rectFullScreen); // fill screen with black
|
||||||
|
|
||||||
|
GrContextForegroundSet(&sContext, ClrBlue);
|
||||||
|
|
||||||
|
// draw gridlines from the center out
|
||||||
|
uint8_t xy_pos;
|
||||||
|
for (xy_pos = HEIGHT/2; xy_pos < HEIGHT; xy_pos += PIXELS_PER_DIV) {
|
||||||
|
GrLineDrawV(&sContext, xy_pos, 0, 128); // right
|
||||||
|
GrLineDrawV(&sContext, HEIGHT - xy_pos, 0, 128); // left
|
||||||
|
|
||||||
|
GrLineDrawH(&sContext, 0, 128, xy_pos); // down
|
||||||
|
GrLineDrawH(&sContext, 0, 128, HEIGHT - xy_pos); // up
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// info
|
||||||
|
GrContextForegroundSet(&sContext, ClrWheat);
|
||||||
|
GrStringDraw(&sContext, gVoltageScaleStr[voltage_scale], /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false);
|
||||||
|
GrStringDraw(&sContext, gTimeScaleStr[time_scale], /*length*/ -1, /*x*/ 60, /*y*/ 0, /*opaque*/ false);
|
||||||
|
//snprintf(str, sizeof(str), "CPU Load %.1f%%", usage_percent);
|
||||||
|
//GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ HEIGHT - 10, /*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
|
||||||
|
GrContextForegroundSet(&sContext, ClrYellow);
|
||||||
|
int j;
|
||||||
|
for(j=0; j<LOCAL_BUF_LEN; j++) {
|
||||||
|
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||||
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
uint32_t upper,lower, current, last;
|
||||||
|
|
||||||
|
if (j==0) {
|
||||||
|
upper = adc_buffer_processed[j];
|
||||||
|
lower = upper;
|
||||||
|
last = upper;
|
||||||
|
} else {
|
||||||
|
current = adc_buffer_processed[j];
|
||||||
|
|
||||||
|
upper = MAX(current, last);
|
||||||
|
lower = MIN(current, last);
|
||||||
|
|
||||||
|
last = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
GrLineDrawV(&sContext, j, lower, upper);
|
||||||
|
}
|
||||||
|
|
||||||
|
GrFlush(&sContext); // flush the frame buffer to the LCD
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue