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.
Revision 2:042e4ea4d82c, committed 2018-05-25
- Comitter:
- el15tcd
- Date:
- Fri May 25 20:32:02 2018 +0000
- Parent:
- 1:c573caf40864
- Commit message:
- UART array transfer test code.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Feb 19 13:09:13 2018 +0000
+++ b/main.cpp Fri May 25 20:32:02 2018 +0000
@@ -8,74 +8,73 @@
DigitalIn bl(p19);
DigitalIn br(p20);
-Serial device(p28,p27); //tx,rx
+Serial device(p28,p27); //tx,rx pins for UART
BusOut myleds(LED4, LED3, LED2, LED1);
-int buffer[4];
+char buffer[4];
int temp1;
int row;
int columns;
-char array[4];
-char matrix[2][2];
+char array[13824];
+char matrix[36][48]; //(48x2x3)/8 x 48
+char sensorTest[36][48]; // i = columns, j = rows
+char buttonTest[2][2];
int i;
int j;
void Array();
void Matrix();
+void Matrix2();
+void SensorSimulate();
int main()
{
-
+ //Matrix2();
myleds = 0;
- device.baud(19200);
- buffer[0] = 1;
- buffer[1] = 0;
- buffer[2] = 1;
- buffer[3] = 0;
+ device.baud(115200); //SET BAUDRATE ON BOTH
+ //buffer[0] = 0xA;
+ //buffer[1] = 1;
+ //buffer[2] = 1;
+ //buffer[3] = 0;
// buffer[4] = 0;
// buffer[5] = 0;
// buffer[6] = 1;
// buffer[7] = 0;
- array[0] = 0;
- array[1] = 0;
- array[2] = 0;
- array[3] = 0;
+ //array[0] = 0;
+ //array[1] = 0;
+ //array[2] = 0;
+ // array[3] = 0;
+
+ SensorSimulate();
while(1) {
- if (tl > 0) {
- myleds = 1;
- } else {
- myleds = 0;
- }
-
- //Array();
+ //Matrix();
+ device.putc(1); //START BIT
- Matrix();
+ for (int j=0; j<36; j++) {
+ for (int i=0; i<48; i++) {
- device.putc(1);
- for (int i=0; i<2; i++) {
- for (int j=0; j<2; j++) {
+ device.putc(sensorTest[i][j]);
- //device.printf("%i",buffer[i]);
-
- //device.putc(buffer[i]);
- device.putc(matrix[i][j]);
}
}
- //wait(1);
+ wait(0.1);
}
+}
-}
+
+
+
void Array()
{
- for(i=0; i<=1 ; i=i+1) {
+ for(i=0; i<=13824 ; i=i+1) {
if (i == 0) {
if (tl > 0) {
array[0] = 1;
@@ -90,6 +89,7 @@
}
}
}
+ /*
for(i=0; i<=1 ; i=i+1) {
if (i == 0) {
if (bl > 0) {
@@ -104,7 +104,7 @@
array[3] = 0;
}
}
- }
+ }*/
/*
for (row=0; row<2; row++) {
for(columns=0; columns<2; columns++) {
@@ -119,24 +119,108 @@
{
if (tl > 0) {
- matrix[0][0] = 1;
+ buttonTest[0][0] = 1;
} else {
- matrix[0][0] = 0;
+ buttonTest[0][0] = 0;
}
if (tr > 0) {
- matrix[0][1] = 1;
+ buttonTest[0][1] = 1;
} else {
- matrix[0][1] = 0;
+ buttonTest[0][1] = 0;
}
if (bl > 0) {
- matrix[1][0] = 1;
+ buttonTest[1][0] = 1;
} else {
- matrix[1][0] = 0;
+ buttonTest[1][0] = 0;
}
if (br > 0) {
- matrix[1][1] = 1;
+ buttonTest[1][1] = 1;
} else {
- matrix[1][1] = 0;
+ buttonTest[1][1] = 0;
}
}
+
+void Matrix2()
+{
+ for (int i=0; i<36; i++) {
+ for (int j=0; j<6; j++) {
+
+ matrix[i][j] = 0xA;
+
+ }
+ }
+}
+
+void SensorSimulate()
+{
+
+ if (tl > 0) {
+ for (int i = 0; i < 24; i++) {
+ for (int j = 0; j < 18; j++) {
+ sensorTest[i][j] = 0x0F;
+
+ }
+ }
+
+ } else {
+ for (int i = 0; i < 24; i++) {
+ for (int j = 0; j < 18; j++) {
+ sensorTest[i][j] = 0xF;
+
+ }
+ }
+ }
+
+ if (tr > 0) {
+ for (int i = 24; i < 48; i++) {
+ for (int j = 0; j < 18; j++) {
+ sensorTest[i][j] = 0xF;
+
+ }
+ }
+
+ } else {
+ for (int i = 24; i < 48; i++) {
+ for (int j = 0; j < 18; j++) {
+ sensorTest[i][j] = 0x0;
+
+ }
+ }
+ }
+
+ if (bl > 0) {
+ for (int i = 0; i < 24; i++) {
+ for (int j = 18; j < 36; j++) {
+ sensorTest[i][j] = 0xF;
+
+ }
+ }
+
+ } else {
+ for (int i = 0; i < 24; i++) {
+ for (int j = 18; j < 36; j++) {
+ sensorTest[i][j] = 0x0;
+
+ }
+ }
+ }
+
+ if (br > 0) {
+ for (int i = 24; i < 48; i++) {
+ for (int j = 18; j < 36; j++) {
+ sensorTest[i][j] = 0xF;
+
+ }
+ }
+
+ } else {
+ for (int i = 24; i < 48; i++) {
+ for (int j = 18; j < 36; j++) {
+ sensorTest[i][j] = 0x0;
+
+ }
+ }
+ }
+}
+