Final project repo for ECE 495
Dependencies: Adafruit_GFX_MBED Adafruit_ILI9341 BurstSPI DS1820 mbed mbed-rtos ltc2991_lib
Diff: main.cpp
- Revision:
- 3:a1b5d7541c69
- Parent:
- 2:0a07f99e32c9
- Child:
- 5:c1c710391df2
--- a/main.cpp Thu Dec 08 20:00:41 2016 +0000 +++ b/main.cpp Thu Dec 08 20:46:50 2016 +0000 @@ -23,6 +23,7 @@ // THREADS Thread display_thread(osPriorityNormal, DEFAULT_STACK_SIZE, NULL); Thread slow_data_thread(osPriorityNormal, DEFAULT_STACK_SIZE, NULL); +Thread serial_thread(osPriorityNormal, DEFAULT_STACK_SIZE, NULL); // DATA VARIABLES double temperatures[NUM_DS1820]; @@ -45,9 +46,10 @@ // setup void ds1820_init(); // thread drivers -void display_cycle(); +void display_task(); void slow_data_task(); void fast_data_task(); +void serial_task(); // data read functions void read_temps(); // ISRs @@ -62,7 +64,7 @@ disp.next_screen(); } -void display_cycle() { +void display_task() { while(1) { disp.update(); Thread::wait(1000); @@ -91,6 +93,17 @@ } } +void fast_data_task() { + +} + +void serial_task() { + while(1) { + pc.printf("PWR: hey"); + Thread::wait(5000); + } +} + // Discover DS1820 probes on pin defined by PIN_DS1820 void ds1820_init() { // Initialize the thermometer array to DS1820 objects @@ -133,34 +146,29 @@ int main() { - - tft.begin(); - tft.fillScreen(RED); - wait_ms(1000); - tft.fillScreen(BLACK); - // Setup serial interrupts, temperature sensors + + // Setup serial interrupts pc.attach(&parse_command); + + // Setup temperature sensors ds1820_init(); - // initialize display + // Setup display tft.begin(); tft.fillScreen(BLACK); tft.setRotation(1); - - // setup display screens TemperatureScreen ts(0, &tft); VoltageScreen vs(1, &tft); CurrentScreen cs(2, &tft); Screen *s[3] = {&ts, &vs, &cs}; disp.set_screens(s, 3); - - // setup display switcher display_interrupt.rise(&display_swap); - // Kick off our threads + // Setup RTOS threads slow_data_thread.start(slow_data_task); wait_ms(1000); - display_thread.start(display_cycle); + display_thread.start(display_task); + serial_thread.start(serial_task); }