a demo of GUI on DISCOF7 consisting of a few buttons and feeders
Dependencies: ADXL345 BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Revision 1:4f356fb65677, committed 2016-08-04
- Comitter:
- habiburrahman
- Date:
- Thu Aug 04 15:36:07 2016 +0000
- Parent:
- 0:122b5c3cbf4d
- Child:
- 2:76522cfa03cd
- Commit message:
- added accelerometer;
Changed in this revision
| ADXL345.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADXL345.lib Thu Aug 04 15:36:07 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/aberk/code/ADXL345/#bd8f0f20f433
--- a/main.cpp Thu Aug 04 15:06:03 2016 +0000
+++ b/main.cpp Thu Aug 04 15:36:07 2016 +0000
@@ -68,7 +68,7 @@
uint16_t feed1_dist = 0;
uint16_t feed2_dist = 0;
-int main()
+int main2()
{
uint16_t x, y;
@@ -81,6 +81,9 @@
lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE);
wait(1);
+
+
+
status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
if (status != TS_OK) {
lcd.Clear(LCD_COLOR_RED);
@@ -153,6 +156,9 @@
if(but1){
lcd.SetTextColor(LCD_COLOR_GREEN);
lcd.FillRect(48, 68, 96, 60);
+
+
+
}
else{
lcd.SetTextColor(LCD_COLOR_RED);
@@ -179,4 +185,49 @@
}
}
+
+
+/////////////////////////////////////////////////////////////////////
+//ACCELEROMETER TEST
+
+#include "ADXL345.h"
+
+ADXL345 accelerometer(D11,D12,D13,D10);
+Serial pc(USBTX, USBRX);
+
+int main() {
+
+ int readings[3] = {0, 0, 0};
+
+ pc.printf("Starting ADXL345 test...\n");
+ pc.printf("Device ID is: 0x%02x\n", accelerometer.getDevId());
+
+ //Go into standby mode to configure the device.
+ accelerometer.setPowerControl(0x00);
+
+ //Full resolution, +/-16g, 4mg/LSB.
+ accelerometer.setDataFormatControl(0x0B);
+
+ //3.2kHz data rate.
+ accelerometer.setDataRate(ADXL345_3200HZ);
+
+ //Measurement mode.
+ accelerometer.setPowerControl(0x08);
+
+ while (1) {
+
+ wait(0.1);
+
+ accelerometer.getOutput(readings);
+
+ //13-bit, sign extended values.
+ pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
+
+ }
+
+}
+
+
+
+
\ No newline at end of file