Libraries and Example of mbed parallel bus using I2C port expanders

Dependencies:   HDSP253X mbed PCF8574_Bus

Committer:
wim
Date:
Sat Aug 20 12:49:44 2011 +0000
Revision:
2:1dab1089c332
Child:
5:38b853bb1afa
First commit, testloop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 2:1dab1089c332 1 /* Status_Display - LED status indicators
wim 2:1dab1089c332 2 * Copyright (c) 2011 Wim Huiskamp
wim 2:1dab1089c332 3 *
wim 2:1dab1089c332 4 * Released under the MIT License: http://mbed.org/license/mit
wim 2:1dab1089c332 5 *
wim 2:1dab1089c332 6 * version 0.2 Initial Release
wim 2:1dab1089c332 7 */
wim 2:1dab1089c332 8 #ifndef _STATUS_DISPLAY_H
wim 2:1dab1089c332 9 #define _STATUS_DISPLAY_H
wim 2:1dab1089c332 10
wim 2:1dab1089c332 11 //Useful stuff to simplify porting of some third party software
wim 2:1dab1089c332 12 #include "Utils.h"
wim 2:1dab1089c332 13
wim 2:1dab1089c332 14 /*****************************************************************************/
wim 2:1dab1089c332 15 /********************* DEFINITIONS FOR STATUS DISPLAY ** ********************/
wim 2:1dab1089c332 16 /*****************************************************************************/
wim 2:1dab1089c332 17
wim 2:1dab1089c332 18 // Specific delays for display operation
wim 2:1dab1089c332 19 #define STATUS_1TCY_WAIT_MS 1
wim 2:1dab1089c332 20
wim 2:1dab1089c332 21 // Definitions for Latch1 of Status LEDs
wim 2:1dab1089c332 22 #define D_STATUS_LED_MULT 0x01
wim 2:1dab1089c332 23 #define D_STATUS_LED_LASER 0x02
wim 2:1dab1089c332 24 #define D_STATUS_LED_BATT 0x04
wim 2:1dab1089c332 25 #define D_STATUS_LED_TEMP 0x08
wim 2:1dab1089c332 26 #define D_STATUS_LED_ENRGY 0x10
wim 2:1dab1089c332 27 #define D_STATUS_LED_NOTUSED_15 0x20
wim 2:1dab1089c332 28 #define D_STATUS_LED_NOTUSED_16 0x40
wim 2:1dab1089c332 29 #define D_STATUS_BACKLIGHT 0x80
wim 2:1dab1089c332 30
wim 2:1dab1089c332 31 // Definitions for Latch2 of Status LEDs
wim 2:1dab1089c332 32 #define D_STATUS_LED_NOTUSED_20 0x01
wim 2:1dab1089c332 33 #define D_STATUS_LED_CODE 0x02
wim 2:1dab1089c332 34 #define D_STATUS_LED_RANGE 0x04
wim 2:1dab1089c332 35 #define D_STATUS_LED_DESIG 0x08
wim 2:1dab1089c332 36 #define D_STATUS_LED_ADDR 0x10
wim 2:1dab1089c332 37 #define D_STATUS_LED_FREQ 0x20
wim 2:1dab1089c332 38 #define D_STATUS_LED_PATH 0x40
wim 2:1dab1089c332 39 #define D_STATUS_LED_NOTUSED_27 0x80
wim 2:1dab1089c332 40
wim 2:1dab1089c332 41
wim 2:1dab1089c332 42 // Definitions for LatchBrightness of Status LEDs
wim 2:1dab1089c332 43 // Value indicates cd/m2
wim 2:1dab1089c332 44 #define D_STATUS_LED_BRIGHT_000 0x00
wim 2:1dab1089c332 45 #define D_STATUS_LED_BRIGHT_022 0x01
wim 2:1dab1089c332 46 #define D_STATUS_LED_BRIGHT_053 0x02
wim 2:1dab1089c332 47 #define D_STATUS_LED_BRIGHT_112 0x03
wim 2:1dab1089c332 48 #define D_STATUS_LED_BRIGHT_253 0x04
wim 2:1dab1089c332 49 #define D_STATUS_LED_BRIGHT_570 0x05
wim 2:1dab1089c332 50 #define D_STATUS_LED_BRIGHT_129 0x06
wim 2:1dab1089c332 51 #define D_STATUS_LED_BRIGHT_360 0x07
wim 2:1dab1089c332 52
wim 2:1dab1089c332 53 // control word masks for Status LEDs
wim 2:1dab1089c332 54 #define STATUS_LED_BRIGHT_MASK 0x07
wim 2:1dab1089c332 55
wim 2:1dab1089c332 56 // Display brightness modes
wim 2:1dab1089c332 57 #define D_STATUS_LED_BRIGHT_OFF D_STATUS_LED_BRIGHT_000
wim 2:1dab1089c332 58 #define D_STATUS_LED_BRIGHT_LOW D_STATUS_LED_BRIGHT_053
wim 2:1dab1089c332 59 #define D_STATUS_LED_BRIGHT_MED D_STATUS_LED_BRIGHT_570
wim 2:1dab1089c332 60 #define D_STATUS_LED_BRIGHT_HGH D_STATUS_LED_BRIGHT_360
wim 2:1dab1089c332 61
wim 2:1dab1089c332 62 // default display brightness
wim 2:1dab1089c332 63 #define D_STATUS_LED_BRIGHT_DEF D_STATUS_LED_BRIGHT_LOW
wim 2:1dab1089c332 64
wim 2:1dab1089c332 65 //Enums for Status LEDs
wim 2:1dab1089c332 66 enum LED_Pin { LED_MULT, LED_LASER, LED_BATT, LED_TEMP, LED_ENRGY, LED_CODE, LED_RANGE, LED_DESIG, LED_ADDR, LED_FREQ, LED_PATH };
wim 2:1dab1089c332 67 enum LED_State { LED_ON, LED_OFF};
wim 2:1dab1089c332 68
wim 2:1dab1089c332 69 //Enums for Brightness
wim 2:1dab1089c332 70 enum Brightness { BRT_OFF, BRT_LOW, BRT_MED, BRT_HIGH };
wim 2:1dab1089c332 71
wim 2:1dab1089c332 72 /** Create a Status_Display object connected to the proper busses
wim 2:1dab1089c332 73 *
wim 2:1dab1089c332 74 * @param PCF8574_DataBus data databus to connect to
wim 2:1dab1089c332 75 * @param PCF8574_EnableBus enable enablebus to connect to
wim 2:1dab1089c332 76 * @param MBED_ControlBus control controlbus to connect to
wim 2:1dab1089c332 77 */
wim 2:1dab1089c332 78 class Status_Display {
wim 2:1dab1089c332 79 public:
wim 2:1dab1089c332 80 Status_Display(PCF8574_DataBus &databus,
wim 2:1dab1089c332 81 PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus);
wim 2:1dab1089c332 82 void lamptest (LED_State led_state);
wim 2:1dab1089c332 83 void LED (LED_Pin led_pin, LED_State led_state);
wim 2:1dab1089c332 84 void NoGo(LED_State NoGo_state);
wim 2:1dab1089c332 85 void backlight (LED_State backlight_state);
wim 2:1dab1089c332 86 void set_brightness(uint8_t brightness);
wim 2:1dab1089c332 87 void set_brightness(Brightness brightness);
wim 2:1dab1089c332 88
wim 2:1dab1089c332 89 protected:
wim 2:1dab1089c332 90 PCF8574_DataBus &_databus;
wim 2:1dab1089c332 91 PCF8574_EnableBus &_enablebus;
wim 2:1dab1089c332 92 MBED_ControlBus &_controlbus;
wim 2:1dab1089c332 93
wim 2:1dab1089c332 94 uint8_t _latch1;
wim 2:1dab1089c332 95 uint8_t _latch2;
wim 2:1dab1089c332 96 uint8_t _brightness;
wim 2:1dab1089c332 97 // void _write_latch1(char data);
wim 2:1dab1089c332 98 // void _write_latch2(char data);
wim 2:1dab1089c332 99 void _write_latch1();
wim 2:1dab1089c332 100 void _write_latch2();
wim 2:1dab1089c332 101 void _write_latchbrightness();
wim 2:1dab1089c332 102 void _init();
wim 2:1dab1089c332 103
wim 2:1dab1089c332 104 };
wim 2:1dab1089c332 105
wim 2:1dab1089c332 106
wim 2:1dab1089c332 107 #endif
wim 2:1dab1089c332 108 /*****************************************************************************/
wim 2:1dab1089c332 109 /****************************** END OF FILE ********************************/
wim 2:1dab1089c332 110 /*****************************************************************************/
wim 2:1dab1089c332 111