CENTER 3D

Dependencies:   EFM32_CapSenseSlider EFM32_SegmentLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
hamid_155
Date:
Thu Feb 25 13:08:48 2016 +0000
Commit message:
CENTER 3D

Changed in this revision

EFM32_CapSense.lib Show annotated file Show diff for this revision Revisions of this file
EFM32_SegmentLCD.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.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ed973aca7da6 EFM32_CapSense.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EFM32_CapSense.lib	Thu Feb 25 13:08:48 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/SiliconLabs/code/EFM32_CapSenseSlider/#8d096e5bc045
diff -r 000000000000 -r ed973aca7da6 EFM32_SegmentLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EFM32_SegmentLCD.lib	Thu Feb 25 13:08:48 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/SiliconLabs/code/EFM32_SegmentLCD/#114aa75da77b
diff -r 000000000000 -r ed973aca7da6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 25 13:08:48 2016 +0000
@@ -0,0 +1,94 @@
+#include "EFM32_SegmentLCD.h"
+#include "EFM32_CapSenseSlider.h"
+
+/******************** Define I/O *****************************/
+InterruptIn in(PB9);
+
+silabs::EFM32_SegmentLCD segmentDisplay;
+silabs::EFM32_CapSenseSlider capSlider;
+
+/******************** Define Timers *****************************/
+LowPowerTicker refreshTicker;
+
+/***************** Define global variables **********************/
+#define INIT_SECONDS		17600
+#define TEST_DURATION		10
+
+volatile uint32_t count = 0, seconds = INIT_SECONDS;
+
+
+/***************** Define callback handlers *********************/
+void tickerCallback(void);
+void in_handler();
+void touchCallback(void);
+void slideCallback(void);
+
+/**
+ * Callback for pushbutton interrupt
+ */
+void in_handler() {
+    count++;
+    segmentDisplay.ARing(count & 0x7, (count & 0x8) == 0);
+}
+
+/**
+ * Callback for 1 second timebase
+ */
+void tickerCallback(void) {
+	seconds++;
+	uint32_t clockValue = ((seconds / 60) % 60) * 100 + (seconds % 60);
+	segmentDisplay.Number(clockValue);
+	segmentDisplay.Symbol(LCD_SYMBOL_COL10, seconds & 0x1);
+}
+
+/**
+ * Callback for touching/untouching the cap slider
+ */
+void touchCallback(void) {
+    segmentDisplay.Symbol(LCD_SYMBOL_EFM32, capSlider.isTouched());
+
+    if(!capSlider.isTouched()) {
+        segmentDisplay.Write("Hello");
+    }
+}
+
+/**
+ * Callback for sliding the cap slider
+ */
+void slideCallback(void) {
+    segmentDisplay.LowerNumber(capSlider.get_position());
+}
+
+/*************************** MAIN *******************************/
+int main() {
+	// Initialize pushbutton handler
+	in.rise(NULL);
+	in.fall(in_handler);
+
+	// Enable the capacitive slider
+	capSlider.start();
+	capSlider.attach_touch(touchCallback);
+	capSlider.attach_untouch(touchCallback);
+	capSlider.attach_slide(-1, slideCallback);
+
+	// Start generating the 1Hz timebase
+	refreshTicker.attach(&tickerCallback, 1.0f);
+
+	printf("Initialization done! \n");
+	wait(0.01f); //Need to delay slightly to give the serial transmission a chance to flush out its buffer
+	segmentDisplay.Write("Hello");
+
+	// Go into sleeping mode
+	while(1)
+	{
+		sleep();
+		if(count >= 8) {
+		    // Go to 'completely dead' mode to show power consumption
+		    refreshTicker.detach();
+		    capSlider.stop();
+		    in.disable_irq();
+		    delete &segmentDisplay;
+		}
+	}
+}
+
diff -r 000000000000 -r ed973aca7da6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 25 13:08:48 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file