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: DRV8830 IQS62x IQSDisplayTerminal UIT_ACM1602NI mbed
Fork of Nucleo_ACM1602_I2C_DC by
Revision 2:ea066749e515, committed 2017-06-07
- Comitter:
- 8mona
- Date:
- Wed Jun 07 15:01:11 2017 +0000
- Parent:
- 1:d5e9bd9b38ad
- Child:
- 3:6474ab60854e
- Commit message:
- 1st Version to enable angle sensor and velocity
Changed in this revision
| 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 |
--- a/main.cpp Fri Apr 01 04:29:04 2016 +0000
+++ b/main.cpp Wed Jun 07 15:01:11 2017 +0000
@@ -5,6 +5,13 @@
//------------------------------------------------------------
#include "ACM1602NI.hpp"
+//Cycle
+#define ON_DURATION 20 //On time [*100ms]
+#define SWITCH_PERIOD 200 //Cycle time[*100ms]
+#define TOTAL_TIMES 10000 //total times n
+#define INITIAL_DELAY 10 //Initial delay for cycle
+
+
using namespace Mikami;
Acm1602Ni lcd_; // Default, OK
@@ -16,32 +23,107 @@
//Acm1602Ni lcd_(PB_4, PA_8); // OK
Ticker timer_;
+DigitalOut Relay1(D2);
+InterruptIn button1(USER_BUTTON);
// Display elapsed time in minutes and seconds
void TimerIsr()
{
static int k = 0;
+ static char ctext[4]="---";
+
+ div_t d_Cycle = div (k, SWITCH_PERIOD);
+
+ //for Current time
+ div_t d_sec = div(k,600); //60s * 10n
+ int t_min = d_sec.quot;
+ div_t d_min = div(t_min,60); //1min=60s
+ int t_hr = d_min.quot;
+
+ //for Current time
+ div_t df_sec = div(TOTAL_TIMES*SWITCH_PERIOD,600); //60s * 10n
+ int tf_min = df_sec.quot;
+ div_t df_min = div(tf_min,60); //1min=60s
+ int tf_hr = df_min.quot;
- div_t ms = div(k, 60);
+
+
+ if(d_Cycle.rem ==INITIAL_DELAY)
+ {
+ Relay1=1;
+ strcpy(ctext," ON");
+ //ctext="ON!";
+ }
+ else if (d_Cycle.rem == (INITIAL_DELAY+ON_DURATION) )
+ {
+ Relay1=0;
+ strcpy(ctext,"OFF");
+ }
+
+
+ if(d_Cycle.quot==TOTAL_TIMES)
+ {
+ timer_.detach();
+ }
+
+
/*
char str[20];
- sprintf(str, "%d'%2d\"", ms.quot, ms.rem);
+ sprintf(str, "%d'%2d\"", msec.quot, msec.rem);
lcd_.WriteStringXY(str, 0, 1);
*/
- lcd_.WriteValueXY("%d'", ms.quot, 0, 1);
- lcd_.WriteValue("%2d\"", ms.rem);
- k++;
+
+ //1 Row
+ //lcd_.WriteStringXY("#",0,0);
+ lcd_.WriteValueXY("%s", ctext, 0,0);
+ lcd_.WriteValue("% 5d/", d_Cycle.quot);
+ lcd_.WriteValue("%0d",TOTAL_TIMES);
+
+ //2 Row
+ lcd_.WriteValueXY("%03dh", t_hr, 0, 1);
+ lcd_.WriteValue("%02dm", d_min.rem);
+ lcd_.WriteValue("%03ds/", d_sec.rem);
+ lcd_.WriteValue("%03dh", tf_hr);
+ lcd_.WriteValue("%02dm", df_min.rem);
+
+
+ k++;
}
+
+
+void flip() {
+ static bool b = false;
+
+ if(b==false)
+ {
+ timer_.attach(&TimerIsr, 0.1);
+ }
+
+ else
+ {
+ timer_.detach();
+ Relay1=0;
+ }
+
+ b=!b;
+
+
+
+}
+
+
int main()
{
+
+ //LCD_cont=0;
if (lcd_.IsConnected()) printf("\r\nConnected");
else printf("\r\nDisconnected");
- lcd_.WriteString("Hello World!");
TimerIsr();
- timer_.attach(&TimerIsr, 1);
+ //timer_.attach(&TimerIsr, 0.1);
+ button1.fall(&flip);
while (true) {}
}
--- a/mbed.bld Fri Apr 01 04:29:04 2016 +0000 +++ b/mbed.bld Wed Jun 07 15:01:11 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/99a22ba036c9 \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file
