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:
khuang
Date:
Fri Aug 26 23:51:06 2016 +0000
Revision:
2:47c3dad2c8ef
Parent:
1:42e8e50ae4ac
Added banner image to text example.;

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 "OLED_types.h"
khuang 1:42e8e50ae4ac 4 #include "OpenSans_Font.h"
khuang 0:a1af4ae04b06 5 #include "string.h"
khuang 2:47c3dad2c8ef 6 #include "images.h"
khuang 0:a1af4ae04b06 7
khuang 0:a1af4ae04b06 8 int main() {
khuang 1:42e8e50ae4ac 9 char text[20]; /* Text Buffer */
khuang 1:42e8e50ae4ac 10 Timer time; /* Instantiate Time */
khuang 0:a1af4ae04b06 11
khuang 1:42e8e50ae4ac 12 /* Instantiate the SSD1351 OLED Driver */
khuang 1:42e8e50ae4ac 13 SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */
khuang 0:a1af4ae04b06 14
khuang 1:42e8e50ae4ac 15 /* Get OLED Class Default Text Properties */
khuang 1:42e8e50ae4ac 16 oled_text_properties_t textProperties = {0};
khuang 1:42e8e50ae4ac 17 oled.GetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 18
khuang 1:42e8e50ae4ac 19 /* Turn on the backlight of the OLED Display */
khuang 1:42e8e50ae4ac 20 oled.DimScreenON();
khuang 1:42e8e50ae4ac 21
khuang 1:42e8e50ae4ac 22 /* Fills the screen with solid black */
khuang 1:42e8e50ae4ac 23 oled.FillScreen(COLOR_BLACK);
khuang 1:42e8e50ae4ac 24
khuang 1:42e8e50ae4ac 25 /* Display Text at (x=7,y=0) */
khuang 1:42e8e50ae4ac 26 strcpy((char *) text,"TEXT EXAMPLE");
khuang 1:42e8e50ae4ac 27 oled.Label((uint8_t *)text,7,0);
khuang 1:42e8e50ae4ac 28
khuang 1:42e8e50ae4ac 29 /* Change font color to blue */
khuang 1:42e8e50ae4ac 30 textProperties.fontColor = COLOR_BLUE;
khuang 0:a1af4ae04b06 31 oled.SetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 32
khuang 1:42e8e50ae4ac 33 /* Display text at (x=5,y=40) */
khuang 0:a1af4ae04b06 34 strcpy(text,"Timer(s):");
khuang 1:42e8e50ae4ac 35 oled.Label((uint8_t *)text,5,40);
khuang 2:47c3dad2c8ef 36
khuang 1:42e8e50ae4ac 37 /* Set text properties to white and right aligned for the dynamic text */
khuang 0:a1af4ae04b06 38 textProperties.fontColor = COLOR_WHITE;
khuang 1:42e8e50ae4ac 39 textProperties.alignParam = OLED_TEXT_ALIGN_RIGHT;
khuang 0:a1af4ae04b06 40 oled.SetTextProperties(&textProperties);
khuang 2:47c3dad2c8ef 41
khuang 2:47c3dad2c8ef 42 /* Adding Banner Image to bottom of screen */
khuang 2:47c3dad2c8ef 43 /* Setting pointer location of the 96 by 32 pixel bitmap */
khuang 2:47c3dad2c8ef 44 const uint8_t *image = NXP_banner_bmp;
khuang 2:47c3dad2c8ef 45 /* Draws the image on the Screen starting at (x=0,y=64) */
khuang 2:47c3dad2c8ef 46 oled.DrawImage(image,0,64);
khuang 0:a1af4ae04b06 47
khuang 1:42e8e50ae4ac 48 time.start(); /* start timer */
khuang 0:a1af4ae04b06 49
khuang 0:a1af4ae04b06 50 while (true) {
khuang 1:42e8e50ae4ac 51
khuang 1:42e8e50ae4ac 52 /* Format the time reading */
khuang 1:42e8e50ae4ac 53 sprintf(text,"%.2f",time.read());
khuang 0:a1af4ae04b06 54
khuang 1:42e8e50ae4ac 55 /* Display time reading in 35px by 15px textbox at(x=55, y=40) */
khuang 2:47c3dad2c8ef 56 oled.TextBox((uint8_t *)text,55,40,35,15); /*Expand textbox for longer amount of time*/
khuang 1:42e8e50ae4ac 57
khuang 0:a1af4ae04b06 58 Thread::wait(1000);
khuang 0:a1af4ae04b06 59 }
khuang 0:a1af4ae04b06 60 }
khuang 0:a1af4ae04b06 61
khuang 0:a1af4ae04b06 62
khuang 0:a1af4ae04b06 63
khuang 0:a1af4ae04b06 64