part of the preparation works for Ina-city Hackerthon
Fork of Wio_3G_example by
Revision 70:cb6d36218441, committed 2018-08-03
- Comitter:
- MACRUM
- Date:
- Fri Aug 03 05:22:15 2018 +0000
- Parent:
- 69:1ff487e9be56
- Child:
- 71:7d17edde2e03
- Commit message:
- Initial commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DigitDisplay.lib Fri Aug 03 05:22:15 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/Seeed/code/DigitDisplay/#d3173c8bfd48
--- a/main.cpp Fri Jun 15 11:00:02 2018 +0100
+++ b/main.cpp Fri Aug 03 05:22:15 2018 +0000
@@ -1,10 +1,79 @@
#include "mbed.h"
+#include "DigitDisplay.h"
+
+#define D20 (PB_4)
+#define D19 (PB_3)
+
+DigitalOut GrovePower(PB_10, 1);
+DigitalOut led1(D38);
+AnalogIn ain(A6);
+InterruptIn btn(D20);
+
+DigitDisplay display(RXD, TXD); // 4-Digit Display connected to UART Grove connector
+
+Ticker ticker;
+volatile uint8_t second = 0;
+volatile uint8_t minute = 0;
+volatile uint8_t hour = 12;
+volatile bool colon_enable = false;
+
+
+///
+
+float get_temp()
+{
+ const int B = 4275; // B value of the thermistor
+ const int R0 = 100000; // R0 = 100k
+ AnalogIn temp(A4);
+
+ float R = 1.0f/temp.read() - 1.0f;
+ R = R0*R;
-DigitalOut led1(LED1);
+ float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet
+ return temperature;
+}
+///
+
+
+void tick()
+{
+ colon_enable = !colon_enable;
+ display.setColon(colon_enable);
+
+ if (colon_enable) {
+ second++;
+ if (second >= 60) {
+ second = 0;
+ minute++;
+ if (minute >= 60) {
+ minute = 0;
+ hour++;
+ if (hour >= 24) {
+ hour = 0;
+ }
+ }
+ display.write(hour * 100 + minute);
+ }
+ }
+}
+
+void push()
+{
+ printf("*");
+}
// main() runs in its own thread in the OS
-int main() {
+int main()
+{
+ display.write(hour * 100 + minute);
+ ticker.attach(tick, 0.5);
+
+ btn.fall(push);
+
+ int cnt = 0;
+ printf("hello, Mbed world\n");
while (true) {
+ printf("count = %4d, analog = %f, temp = %f\n", cnt++, ain.read(), get_temp());
led1 = !led1;
wait(0.5);
}
--- a/mbed-os.lib Fri Jun 15 11:00:02 2018 +0100 +++ b/mbed-os.lib Fri Aug 03 05:22:15 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#866850acc15e86cd4ac11bf4404078a49f921ddd +https://github.com/ARMmbed/mbed-os/#50bd61a4a72332baa6b1bac6caccb44dc5423309
