.

Dependencies:   eeprom keypad mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
583405000008
Date:
Sun Dec 04 00:16:17 2016 +0000
Commit message:
d

Changed in this revision

eeprom.lib Show annotated file Show diff for this revision Revisions of this file
keypad.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b4c98e0b828d eeprom.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eeprom.lib	Sun Dec 04 00:16:17 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/FRA221_2015/code/eeprom/#df82ebf4be54
diff -r 000000000000 -r b4c98e0b828d keypad.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keypad.lib	Sun Dec 04 00:16:17 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/yoonghm/code/keypad/#da060f8c03e8
diff -r 000000000000 -r b4c98e0b828d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 04 00:16:17 2016 +0000
@@ -0,0 +1,130 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "Keypad.h"
+#include "eeprom.h"
+#include "stdlib.h"
+
+//EEPROM memory(I2C_SDA,I2C_SCL,0);
+Serial PC(D1, D0);
+ // Define your own keypad values
+ char Keytable[] = { '1', '2', '3', 'A',   // r0
+                     '4', '5', '6', 'B',   // r1
+                     '7', '8', '9', 'C',   // r2
+                     '*', '0', '#', 'D'    // r3
+                   };
+                  // c0   c1   c2   c3
+ 
+ uint32_t Index;
+ uint32_t oldIndex;
+ string arraysong[4][5] ={{"1A", "2A", "3A","4A", "5A"},
+                          {"1B", "2B", "3B","4B", "5B"},
+                          {"1C", "2C", "3C","4C", "5C"},
+                          {"1D", "2D", "3D","4D", "5D"},}; //keep name's songs to random
+                          
+ char like; // if user likes, it send "l" /dislikes send "d" / wants to pass send "o"
+ 
+ uint32_t cbAfterInput(uint32_t index) {
+     Index = index;
+     return 0;
+ }
+ int randomja();
+ int numra; // a number gets from randomja()
+ 
+ int main() {
+                 // r0   r1   r2   r3   c0   c1   c2   c3
+     Keypad keypad(A5, A4, D2,D3, D4, D5, D6, D7);
+     keypad.attach(&cbAfterInput);
+     keypad.start();  // energize the keypad via c0-c3
+ 
+     while (1) {
+         __wfi();
+         //printf("Interrupted\r\n");
+         //PC.printf("Index:%d\n",Index);
+         //PC.printf("oldIndex:%d\n",oldIndex);
+         //wait_ms(1000);
+         
+       while (oldIndex != Index){           
+           PC.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
+           if (Index == 4){
+             numra = rand()%5;
+             printf("Jibinarak4 %d\n",numra);
+             printf("song is %s\n",arraysong[Index-4][numra]);
+          /*   memory.write(1,Index,1);
+             wait_ms(1);
+             memory.write(2,arraysong,100);
+             wait_ms(1);             
+         */    
+             Index =0; numra = 0; 
+             oldIndex = Index; 
+             }
+           else if (Index == 5){
+             numra = rand()%5;
+             printf("Jibinarak5 %d\n",numra);
+             printf("song is %s\n",arraysong[Index-4][numra]);
+          /*   memory.write(3,Index,1);
+             wait_ms(1);
+             memory.write(4,arraysong,100);
+             wait_ms(1);
+           */
+             Index =0; numra = 0;   
+             oldIndex = Index; 
+             }
+           else if (Index == 6){
+             numra = rand()%5;
+             printf("Jibinarak6 %d\n",numra);
+             PC.printf("song is %s\n",arraysong[Index-4][numra]);
+           /*  memory.write(5,Index,1);
+             wait_ms(1);
+             memory.write(6,arraysong,100);
+             wait_ms(1);
+           */
+             Index =0; numra = 0;   
+             oldIndex = Index; 
+             }
+           else if (Index == 7){
+             numra = rand()%5;
+             printf("Jibinarak7 %d\n",numra);
+             PC.printf("song is %s\n",arraysong[Index-4][numra]);
+           /*  memory.write(7,Index,1);
+             wait_ms(1);
+             memory.write(8,arraysong,100);
+             wait_ms(1);
+           */  
+             Index =0; numra = 0;   
+             oldIndex = Index; 
+             }
+           else if (Index == 8){
+             like = 'l';
+             printf("like : %c\n",like);
+             
+           /*  memory.write(9,Index,1);
+             wait_ms(1);
+             memory.write(10,like,1);
+             wait_ms(1);
+           */  oldIndex = Index; 
+             }
+           else if (Index == 9){
+             like = 'd';
+             printf("like : %c\n",like);
+    
+           /*  memory.write(11,Index,1);
+             wait_ms(1);
+             memory.write(12,like,1);
+             wait_ms(1);
+          */   oldIndex = Index; 
+             }
+           else if (Index == 10){
+             like = 'o';
+             printf("like : %c\n",like);
+             
+          /*   memory.write(13,Index,1);
+             wait_ms(1);
+             memory.write(14,like,1);
+             wait_ms(1);
+           */  oldIndex = Index; 
+             }
+           else{oldIndex = Index;}  
+         }
+     }
+     
+ }
\ No newline at end of file
diff -r 000000000000 -r b4c98e0b828d mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sun Dec 04 00:16:17 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
diff -r 000000000000 -r b4c98e0b828d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 04 00:16:17 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file