iBreathe Breathalyzer can now talk thanks to the Text to Speech Click Board

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 text_to_speak_mbed

Fork of iBreathe_Breathalyzer by Dave Clarke

Committer:
cotigac
Date:
Sun Aug 28 16:48:46 2016 +0000
Revision:
4:4e35f2e4b786
Parent:
3:d633281e5f83
Child:
5:a27fdb811237
removed dependencies to font and oled types

Who changed what in which revision?

UserRevisionLine numberNew contents of line
khuang 0:a1af4ae04b06 1 #include "mbed.h"
khuang 0:a1af4ae04b06 2 #include "Hexi_OLED_SSD1351.h"
khuang 0:a1af4ae04b06 3 #include "string.h"
khuang 0:a1af4ae04b06 4
khuang 0:a1af4ae04b06 5 int main() {
khuang 1:42e8e50ae4ac 6 char text[20]; /* Text Buffer */
khuang 1:42e8e50ae4ac 7 Timer time; /* Instantiate Time */
khuang 0:a1af4ae04b06 8
khuang 1:42e8e50ae4ac 9 /* Instantiate the SSD1351 OLED Driver */
khuang 1:42e8e50ae4ac 10 SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */
khuang 0:a1af4ae04b06 11
khuang 1:42e8e50ae4ac 12 /* Get OLED Class Default Text Properties */
khuang 1:42e8e50ae4ac 13 oled_text_properties_t textProperties = {0};
khuang 1:42e8e50ae4ac 14 oled.GetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 15
khuang 1:42e8e50ae4ac 16 /* Turn on the backlight of the OLED Display */
khuang 1:42e8e50ae4ac 17 oled.DimScreenON();
khuang 1:42e8e50ae4ac 18
khuang 1:42e8e50ae4ac 19 /* Fills the screen with solid black */
khuang 1:42e8e50ae4ac 20 oled.FillScreen(COLOR_BLACK);
khuang 1:42e8e50ae4ac 21
khuang 1:42e8e50ae4ac 22 /* Display Text at (x=7,y=0) */
khuang 1:42e8e50ae4ac 23 strcpy((char *) text,"TEXT EXAMPLE");
khuang 1:42e8e50ae4ac 24 oled.Label((uint8_t *)text,7,0);
khuang 1:42e8e50ae4ac 25
khuang 1:42e8e50ae4ac 26 /* Change font color to blue */
khuang 1:42e8e50ae4ac 27 textProperties.fontColor = COLOR_BLUE;
khuang 0:a1af4ae04b06 28 oled.SetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 29
khuang 1:42e8e50ae4ac 30 /* Display text at (x=5,y=40) */
khuang 0:a1af4ae04b06 31 strcpy(text,"Timer(s):");
khuang 1:42e8e50ae4ac 32 oled.Label((uint8_t *)text,5,40);
khuang 0:a1af4ae04b06 33
khuang 1:42e8e50ae4ac 34 /* Set text properties to white and right aligned for the dynamic text */
khuang 0:a1af4ae04b06 35 textProperties.fontColor = COLOR_WHITE;
khuang 1:42e8e50ae4ac 36 textProperties.alignParam = OLED_TEXT_ALIGN_RIGHT;
khuang 0:a1af4ae04b06 37 oled.SetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 38
khuang 1:42e8e50ae4ac 39
khuang 1:42e8e50ae4ac 40 time.start(); /* start timer */
khuang 0:a1af4ae04b06 41
khuang 0:a1af4ae04b06 42 while (true) {
khuang 1:42e8e50ae4ac 43
khuang 1:42e8e50ae4ac 44 /* Format the time reading */
khuang 1:42e8e50ae4ac 45 sprintf(text,"%.2f",time.read());
khuang 0:a1af4ae04b06 46
khuang 1:42e8e50ae4ac 47 /* Display time reading in 35px by 15px textbox at(x=55, y=40) */
khuang 3:d633281e5f83 48 oled.TextBox((uint8_t *)text,55,40,35,15); //Increase textbox for more digits
khuang 1:42e8e50ae4ac 49
khuang 0:a1af4ae04b06 50 Thread::wait(1000);
khuang 0:a1af4ae04b06 51 }
khuang 0:a1af4ae04b06 52 }
khuang 0:a1af4ae04b06 53
khuang 0:a1af4ae04b06 54
khuang 0:a1af4ae04b06 55
khuang 0:a1af4ae04b06 56