A program that simulates a simple stopwatch program using three buttons, and uses LEDs and vibration as feedback to the buttons.

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351

Committer:
fusop
Date:
Wed Apr 19 15:00:09 2017 +0000
Revision:
0:623612f2cc48
Final version of Stopwatch;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fusop 0:623612f2cc48 1
fusop 0:623612f2cc48 2
fusop 0:623612f2cc48 3 extern void Button_Init (void);
fusop 0:623612f2cc48 4 extern void StartHP (void);
fusop 0:623612f2cc48 5 extern void StopHP (void const *n);
fusop 0:623612f2cc48 6 extern DigitalOut hp(PTB9);
fusop 0:623612f2cc48 7 extern KW40Z kw40z_device(PTE24, PTE25);
fusop 0:623612f2cc48 8 extern RtosTimer hpTime(StopHP, osTimerOnce);
fusop 0:623612f2cc48 9 extern int but;
fusop 0:623612f2cc48 10
fusop 0:623612f2cc48 11 void StartHP (void);
fusop 0:623612f2cc48 12 void StopHP (void const *n);
fusop 0:623612f2cc48 13
fusop 0:623612f2cc48 14 int but = 1;
fusop 0:623612f2cc48 15
fusop 0:623612f2cc48 16 //Buttons-------------------------------
fusop 0:623612f2cc48 17
fusop 0:623612f2cc48 18 void ButtonUp(void)
fusop 0:623612f2cc48 19 {
fusop 0:623612f2cc48 20 StartHP();
fusop 0:623612f2cc48 21 }
fusop 0:623612f2cc48 22
fusop 0:623612f2cc48 23 void ButtonDown(void)
fusop 0:623612f2cc48 24 {
fusop 0:623612f2cc48 25 StartHP();
fusop 0:623612f2cc48 26 but = 0;
fusop 0:623612f2cc48 27 }
fusop 0:623612f2cc48 28
fusop 0:623612f2cc48 29 void ButtonRight(void)
fusop 0:623612f2cc48 30 {
fusop 0:623612f2cc48 31 StartHP();
fusop 0:623612f2cc48 32 but = 1;
fusop 0:623612f2cc48 33 }
fusop 0:623612f2cc48 34
fusop 0:623612f2cc48 35 void ButtonLeft(void)
fusop 0:623612f2cc48 36 {
fusop 0:623612f2cc48 37 StartHP();
fusop 0:623612f2cc48 38 but = 2;
fusop 0:623612f2cc48 39 }
fusop 0:623612f2cc48 40
fusop 0:623612f2cc48 41 void ButtonSlide(void)
fusop 0:623612f2cc48 42 {
fusop 0:623612f2cc48 43 StartHP();
fusop 0:623612f2cc48 44 }
fusop 0:623612f2cc48 45
fusop 0:623612f2cc48 46 void Button_Init (void)
fusop 0:623612f2cc48 47 {
fusop 0:623612f2cc48 48 kw40z_device.attach_buttonUp(&ButtonUp);
fusop 0:623612f2cc48 49 kw40z_device.attach_buttonDown(&ButtonDown);
fusop 0:623612f2cc48 50 kw40z_device.attach_buttonLeft(&ButtonLeft);
fusop 0:623612f2cc48 51 kw40z_device.attach_buttonRight(&ButtonRight);
fusop 0:623612f2cc48 52 }
fusop 0:623612f2cc48 53
fusop 0:623612f2cc48 54 //Haptic -----------------------------------------
fusop 0:623612f2cc48 55
fusop 0:623612f2cc48 56 void StartHP(void)
fusop 0:623612f2cc48 57 {
fusop 0:623612f2cc48 58 hpTime.start(50);
fusop 0:623612f2cc48 59 hp = 1;
fusop 0:623612f2cc48 60 }
fusop 0:623612f2cc48 61
fusop 0:623612f2cc48 62 void StopHP(void const *n)
fusop 0:623612f2cc48 63 {
fusop 0:623612f2cc48 64 hp = 0;
fusop 0:623612f2cc48 65 hpTime.stop();
fusop 0:623612f2cc48 66 }