:)
Dependencies: MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2
Revision 0:16d2619002d7, committed 2014-11-18
- Comitter:
- ddrew73
- Date:
- Tue Nov 18 01:20:00 2014 +0000
- Child:
- 1:0183a7d38878
- Commit message:
- It works!
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_LEDBackpack.lib Tue Nov 18 01:20:00 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/luizhespanha/code/Adafruit_LEDBackpack/#0491b3f9a639
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DebounceIn.lib Tue Nov 18 01:20:00 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Nov 18 01:20:00 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Tue Nov 18 01:20:00 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Nov 18 01:20:00 2014 +0000
@@ -0,0 +1,163 @@
+#include "mbed.h"
+#include "Adafruit_LEDBackpack.h"
+#include "Adafruit_GFX.h"
+#include "TextLCD.h"
+#include "DebounceIn.h"
+#include "USBKeyboard.h"
+
+//LED stuff
+I2C i2c(D7,D6);
+Adafruit_24bargraph ledbar=Adafruit_24bargraph(&i2c);
+DebounceIn upbutton(D9);
+DebounceIn downbutton(D8);
+
+
+//Scanner stuff
+
+DebounceIn scanbutton(D10);
+
+DigitalOut A_in(D0);
+DigitalOut B_in(D1);
+DigitalOut C_in(D2);
+
+DigitalOut A_out(PTC7);
+DigitalOut B_out(PTC0);
+DigitalOut C_out(PTC3);
+
+AnalogOut dac(PTE30);
+AnalogIn adc(PTB0);
+
+//USBKeyboard keyboard;
+
+
+//LCD stuff
+//TextLCD lcd(PTD0,PTD5,PTA12,PTD4,PTA2,PTA1,TextLCD::LCD20x4);
+
+int main()
+{
+
+ //Scan init
+
+ float test_val = .001;
+ int con_mat[8][8] = {};
+ int a1,b1,c1,a2,b2,c2;
+ //dac = test_val;
+
+
+ //LED init
+ int redcount = 0, greencount = 0, rowselect = 0, rowselect_old = 0, moved = 1;
+ ledbar.begin(0x70);
+ ledbar.clear();
+ ledbar.writeDisplay();
+
+ //LCD init
+ /*
+ lcd.cls();
+ string programname = "Dan's UI Test"
+ float vddmeasure = 3.14259;
+ lcd.printf("%s",programname.c_str()); //Is the .c_str necessary? Some people on stack overflow say so...
+ lcd.locate(0,2);
+ lcd.printf("%1.3f",vddmeasure);
+ */
+
+
+
+ while(1) {
+
+
+ //Display
+
+ ledbar.setBar(rowselect_old,LED_OFF);
+ ledbar.setBar(rowselect,LED_GREEN);
+ ledbar.writeDisplay();
+
+
+ //Moving the selected row
+ if (upbutton.read() == 0) {
+ rowselect_old = rowselect;
+ rowselect = rowselect-1;
+ moved = 1;
+ wait(0.75);
+ }
+
+ if (downbutton.read() == 0) {
+ rowselect_old = rowselect;
+ rowselect = rowselect+1;
+ moved = 1;
+ wait(0.75);
+ }
+
+ //Boundary checking
+ if (rowselect > 23) {
+ rowselect = 23;
+ }
+ if (rowselect < 0) {
+ rowselect = 0;
+ }
+
+ //Implementing scanning
+
+ if (scanbutton.read() == 0) {
+
+ for (int x = 0; x < 8; x++) {
+ for (int y = 0; y < 8; y++) {
+ // Stupid logic to convert count value to binary...
+ A_in = x%2;
+ a1 = x%2;
+ B_in = (x/2)%2;
+ b1 = (x/2)%2;
+ C_in = (x/4)%2;
+ c1 = (x/4)%2;
+
+ A_out = y%2;
+ int a2 = y%2;
+ B_out = (y/2)%2;
+ b2 = (y/2)%2;
+ C_out = (y/4)%2;
+ c2 = (y/4)%2;
+
+ // Now we do the scan test, results are stored in con_mat
+ //wait(0.01);
+ dac = test_val;
+ float in_val = adc.read();
+
+ if ((in_val > .0010) && (in_val < .0025))
+ con_mat[x][y] = 1;
+ else
+ con_mat[x][y] = 0;
+
+ //keyboard.printf("%f %f \n",dac.read(),in_val);
+ //keyboard.printf("%d %d %d\n",a2,b2,c2);
+ }
+ }
+
+ /*
+ for (int x=0;x<8;x++) {
+ for (int y=0;y<8;y++) {
+ keyboard.printf("%d ",con_mat[x][y]);
+ }}
+ */
+ //Displaying all connected rows as red light!
+ ledbar.clear();
+ for (int i=0; i<8; i++) {
+ if (con_mat[rowselect][i] == 1) {
+ ledbar.setBar(i,LED_RED);
+ }
+ }
+ ledbar.writeDisplay();
+ moved = 0;
+ wait(2.5);
+ ledbar.clear();
+ ledbar.writeDisplay();
+
+ }
+ }
+
+
+
+
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 18 01:20:00 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file