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.
Dependencies: mRotaryEncoder mbed
Revision 0:b2d0595444a4, committed 2016-03-06
- Comitter:
- ostlerkd13
- Date:
- Sun Mar 06 06:58:22 2016 +0000
- Commit message:
- Test program with function for Min and Max value returned from encoder.; ISR for switch-press that that toggles resolution from 1X to 10X.
Changed in this revision
diff -r 000000000000 -r b2d0595444a4 mRotaryEncoder.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mRotaryEncoder.lib Sun Mar 06 06:58:22 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/charly/code/mRotaryEncoder/#2502b829d452
diff -r 000000000000 -r b2d0595444a4 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Mar 06 06:58:22 2016 +0000
@@ -0,0 +1,57 @@
+/**************************************************************************************/
+/**************************************************************************************/
+/*SMART Remote Controller
+
+ Kevin D. Ostler copyright 2016 */
+/**************************************************************************************/
+/**************************************************************************************/
+#include "mbed.h"
+#include "mRotaryEncoder.h"
+#define MAX 100
+#define MIN 0
+
+mRotaryEncoder adjust_enc(p9, p10, p11);//pinA,pinB,pinSW
+
+float resolution = 1.0;
+float adjust_set = 0.0;
+float adjust_last = 0.0;
+bool button = 1;
+
+float AdjustVal(float adjust_val){
+ adjust_val += (adjust_enc.Get() * resolution);
+ if( adjust_val >= MAX){
+ adjust_val = MAX;
+ }else if(adjust_val <= MIN){
+ adjust_val = MIN;
+ }
+ adjust_enc.Set(0);
+ return adjust_val;
+}
+void Set_Resolution(void){
+ button = !button;
+ if( resolution == 1.0 ){
+ resolution = 0.1;
+ }else{
+ resolution = 1.0;
+ }
+}
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+ pc.baud(921600);
+ pc.format(8,Serial::None,1);
+ wait(0.1);
+ adjust_enc.attachSW( &Set_Resolution);
+ while(1) {
+ myled = 1;
+ adjust_set = AdjustVal(adjust_set);
+ //adjust_last = adjust_set;
+ pc.printf("Adjust Level = %f Resolution = %f Button = %d\n\r" ,adjust_set/100, resolution, button);
+ wait(0.2);
+ myled = 0;
+ pc.printf("Adjust Level = %f Resolution = %f Button = %d\n\r" ,adjust_set/100, resolution, button);
+ wait(0.2);
+ }
+}
diff -r 000000000000 -r b2d0595444a4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 06 06:58:22 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file