Collections of BERTL libraries

Committer:
DongExpander
Date:
Mon Apr 18 12:48:42 2016 +0000
Revision:
3:1708f20fd55b
Parent:
1:b924729b5734
Feature; Added initialize()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DongExpander 1:b924729b5734 1 #ifndef hl_bertl_portex
DongExpander 1:b924729b5734 2 #define hl_bertl_portex
DongExpander 1:b924729b5734 3
DongExpander 1:b924729b5734 4 const int BTN_FLL = 0x80;
DongExpander 1:b924729b5734 5 const int BTN_FL = 0x04;
DongExpander 1:b924729b5734 6 const int BTN_FM = 0x01;
DongExpander 1:b924729b5734 7 const int BTN_FR = 0x08;
DongExpander 1:b924729b5734 8 const int BTN_FRR = 0x40;
DongExpander 1:b924729b5734 9 const int BTN_BL = 0x10;
DongExpander 1:b924729b5734 10 const int BTN_BM = 0x02;
DongExpander 1:b924729b5734 11 const int BTN_BR = 0x20;
DongExpander 1:b924729b5734 12
DongExpander 1:b924729b5734 13 const int LED_FL1 = 0x01; // white die vordere
DongExpander 1:b924729b5734 14 const int LED_FL2 = 0x02; // red die hintere
DongExpander 1:b924729b5734 15 const int LED_FR1 = 0x04; // white
DongExpander 1:b924729b5734 16 const int LED_FR2 = 0x08; // red
DongExpander 1:b924729b5734 17 const int LED_ALL_FRONT = 0x0F;
DongExpander 1:b924729b5734 18
DongExpander 1:b924729b5734 19 const int LED_BL1 = 0x20; // red back left outher
DongExpander 1:b924729b5734 20 const int LED_BL2 = 0x10; // red back left inner
DongExpander 1:b924729b5734 21 const int LED_BR1 = 0x80; // red back right outher
DongExpander 1:b924729b5734 22 const int LED_BR2 = 0x40; // red back right inner
DongExpander 1:b924729b5734 23 const int LED_ALL_BACK = 0xF0;
DongExpander 1:b924729b5734 24
DongExpander 1:b924729b5734 25
DongExpander 1:b924729b5734 26 class PortEx
DongExpander 1:b924729b5734 27 {
DongExpander 1:b924729b5734 28 public:
DongExpander 1:b924729b5734 29 // Current State of Buttons is refreshed with ReadButtons()
DongExpander 1:b924729b5734 30 int16_t btns;
DongExpander 1:b924729b5734 31 uint8_t btnEvent;
DongExpander 1:b924729b5734 32 uint8_t useISR;
DongExpander 1:b924729b5734 33 public:
DongExpander 1:b924729b5734 34 PortEx();
DongExpander 1:b924729b5734 35 void Init();
DongExpander 1:b924729b5734 36
DongExpander 1:b924729b5734 37 void SetLedPort(uint8_t aBitPattern); // NO local Bit-OR
DongExpander 1:b924729b5734 38 void SetLeds(uint8_t aBitPattern);
DongExpander 1:b924729b5734 39 void ToggleLeds(uint8_t aBitPattern);
DongExpander 1:b924729b5734 40 void ClearLeds();
DongExpander 1:b924729b5734 41
DongExpander 1:b924729b5734 42 void ReadButtons();
DongExpander 1:b924729b5734 43 void WaitUntilButtonPressed();
DongExpander 1:b924729b5734 44 void WaitUntilFrontButtonPressed();
DongExpander 1:b924729b5734 45
DongExpander 1:b924729b5734 46 bool IsButton(int aBitPattern) {
DongExpander 1:b924729b5734 47 return btns & aBitPattern;
DongExpander 1:b924729b5734 48 }
DongExpander 1:b924729b5734 49
DongExpander 1:b924729b5734 50 bool IsAnyFrontButton() {
DongExpander 1:b924729b5734 51 return btns & (BTN_FL|BTN_FM|BTN_FR);
DongExpander 1:b924729b5734 52 }
DongExpander 1:b924729b5734 53
DongExpander 1:b924729b5734 54 bool IsAnyBackButton() {
DongExpander 1:b924729b5734 55 return btns & (BTN_BL|BTN_BM|BTN_BR);
DongExpander 1:b924729b5734 56 }
DongExpander 1:b924729b5734 57 private:
DongExpander 1:b924729b5734 58 uint8_t _currLeds;
DongExpander 1:b924729b5734 59 void p6ISR();
DongExpander 1:b924729b5734 60 I2C _i2c;
DongExpander 1:b924729b5734 61 const int DEV = 0x40;
DongExpander 1:b924729b5734 62 InterruptIn _p6Event;
DongExpander 1:b924729b5734 63 };
DongExpander 1:b924729b5734 64
DongExpander 1:b924729b5734 65 #endif
DongExpander 1:b924729b5734 66