Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of idd_hw2_antoniorohit_3x3CharDrawing by
Diff: main.cpp
- Revision:
- 1:e04bcbc40115
- Parent:
- 0:1aa14f2daf0e
--- a/main.cpp Sun Sep 21 15:43:40 2014 +0000 +++ b/main.cpp Mon Sep 22 08:31:42 2014 +0000 @@ -11,7 +11,7 @@ DigitalIn p10(D10); DigitalIn p11(D11); DigitalIn p12(D12); -DigitalIn p13(D13); +DigitalIn p13(D14); DigitalOut led(LED1); DigitalOut led2(LED2); @@ -10379,12 +10379,13 @@ 127, 128, 127, 128}; const char Space[NUM_ELEMENTS] = {}; - const char Del[NUM_ELEMENTS] = {}; int main() { int value = 0; + char pc_val; + p2.mode(PullUp); p3.mode(PullUp); p4.mode(PullUp); @@ -10433,6 +10434,9 @@ if(p12 == 0){ //backspace value = 513; } + if(p13 == 0){ //something else + value = 514; + } if(value!=0) @@ -10444,11 +10448,19 @@ led = 1; } pc.printf("%d\n", value); + + if(value>511) + wait_ms(100); //debounce - mechanical switches + if(pc.readable()) { - led2 = 0; - switch(pc.getc()) + pc_val = pc.getc(); + if(pc_val > '0') + { + led2 = 0; + } + switch(pc_val) { case 'a': case 'A': @@ -10691,13 +10703,7 @@ // //import processing.serial.*; // -//int SIZE_OF_BOX = 100; -//int GREY = 204; -//int BLACK = 0; -//int WHITE = 255; -//int NUM_BTNS = 9; -//int i = 1; -//int character = 0; +// //char array[] = { //0, // 0 //0, // 1 @@ -11213,15 +11219,22 @@ //'M', // 511 //' ', // 512 - Space //10, // 513 backspace -// +//0, // 514 - TBD button //}; // // //Serial myPort; // Create object from Serial class +//int SIZE_OF_BOX = 100; +//int GREY = 204; +//int BLACK = 0; +//int WHITE = 255; +//int NUM_BTNS = 9; +// +//int i = 1; +//int character = 0; //int val;// Data received from the serial port //int aggregate_val; //int temp; -//int color_array[] = {0,0,0,0,0,0,0,0,0}; //int timeout = 1; //String words = ""; //int word_len = 0; @@ -11238,9 +11251,9 @@ // //void draw() //{ -// background(0); // Set background to black +// background(0); // Set background to black // -// timeout = millis();; +// timeout = millis(); // aggregate_val = 0; // while((millis()-timeout) < 1000) // { @@ -11260,15 +11273,19 @@ // val = val/(i*10); // } // -// aggregate_val |= val; +// if(val < 512) +// aggregate_val |= val; +// else +// { +// aggregate_val = val; +// timeout = millis()-1000; +// } +// print("Aggregate Value: ", aggregate_val, "\n"); // -// print("Aggregate Value: ", aggregate_val); -// -// if(val != 0) +// if(val != 0 && val < 512) // { // timeout = millis(); // } -// print("Timeout: ", millis()-timeout, '\n'); // // } // } @@ -11296,15 +11313,27 @@ // break; // } // +// draw_char(aggregate_val); // text("Current key: " + current_key, 10, 320, 290, 330); // text("Input Text: " + words, 10, 340, 290, 390); +//} +// +//void draw_char(int ag_val) +//{ +// int color_array[] = {0,0,0,0,0,0,0,0,0}; // -// if(aggregate_val < 512) // 9 squares, 2^9 values :) +// if(ag_val < 512) // 9 squares, 2^9 values :) +// for(int p = 0; p < 9; p++) +// { +// color_array[p] = (((ag_val) & (0x01<<p))>0 ? GREY : WHITE); +// } +// else +// { // for(int p = 0; p < 9; p++) -// { -// color_array[p] = (((aggregate_val) & (0x01<<p))>0 ? GREY : WHITE); -// } -// +// { +// color_array[p] = (WHITE); +// } +// } // fill(color_array[0]); // rect(0*SIZE_OF_BOX, 0*SIZE_OF_BOX, SIZE_OF_BOX, SIZE_OF_BOX); // fill(color_array[1]); @@ -11324,6 +11353,4 @@ // fill(color_array[8]); // rect(2*SIZE_OF_BOX, 2*SIZE_OF_BOX, SIZE_OF_BOX, SIZE_OF_BOX); // -// -// //}