lab1

  1. include "mbed.h"
  2. include "et095g.h"

/* To get access to the library functions, we need to create an object of the ET095G class. The name of this object is up to you. */ ET095G app;

bool pb1 = false; bool pb0 = false;

/* The ET095G library generates a periodic tick (default interval every 0.2s). So everything you write in this function will happen periodically. */ void tick_handler() { Code that should execute on every tick. }

/* This code is executed when PB0 is pressed. */ void pb0_handler() { pb0 = true; pb1 = false; }

void tempHum() { float temp = app.get_temperature(); app.display.locate(0,1); app.display.printf("Temp: %02f", temp); app.display.update();

float humi = app.get_humidity(); app.display.locate(0,4); app.display.printf("Humi: %02f", humi); app.display.update(); }

void graph() { while(1) { float maxTemp = 1; float temp1 = app.get_temperature(); float hx = temp; float i = 0; app.display(4, hx, 20+i, 80); i++; } app.display.rect(10,10,50,50,Black);

}

/* This code is executed when PB1 is pressed.*/ void pb1_handler() { pb1 = true; pb0 = false; }

/* The main function of our program. */ int main() { app.display.clearImmediate(); Clear the display on startup

The wait function in mbed can be used to add delays (in seconds) to your program. wait(1);

while(1) { You can access library functions via the class instance 'app' app.toggle_led0(); wait(1); /* app.display.locate(0,5); app.display.printf("Left: Numbers \nRight: Graphs"); app.display.update(); */

if(pb1 == true) { tempHum(); } else graph(); } }


Please log in to post comments.