HDSP253X Smart Alphanumeric LED matrix display
Embed:
(wiki syntax)
Show/hide line numbers
HDSP253X.h
00001 /* HDSP253X_Display - Intelligent 8 digit 5x7 LED matrix display 00002 * 00003 * Copyright (c) 2011 Wim Huiskamp 00004 * Modified software based on sourcecode by RAC 06/08/2008 00005 * 00006 * Released under the MIT License: http://mbed.org/license/mit 00007 * 00008 * version 0.2 Initial Release 00009 */ 00010 #ifndef MBED_HDSP253X_H 00011 #define MBED_HDSP253X_H 00012 /*---------------------------------------------------------------------------*\ 00013 | Original text by RAC 06/08/2008 has been modified to fix those parts of 00014 | the description which explain hardware or software that has been removed or 00015 | adapted in the new version. 00016 | 00017 | Description: Display driver and demonstrator for HDSP253X series intelligent 00018 | 8 character LED display modules. Options include adjusting 00019 | brightness and message blinking. 00020 | This software drives a single display module using 8 bit databus, 00021 | 5 bit addressbus and controlsignals. Note that this software 00022 | will drive all display devices in the series, including HDSP2530 Orange, 00023 | HDSP2531 Yellow, HDSP2532 red and HDSP2533 green devices. It will also 00024 | drive the smaller HDSP21XX series. 00025 | 00026 | The peripheral is connected to the following pins: 00027 | HDSP253X 00028 | - Reset (pin 1) to EnableBus.RESET 00029 | - Flash (pin 2) to AddressBus.A5 00030 | - Addr A0 (pin 3) to AddressBus.A0 00031 | - Addr A1 (pin 4) to AddressBus.A1 00032 | - Addr A2 (pin 5) to AddressBus.A2 00033 | - Addr A3 (pin 6) to AddressBus.A3 00034 | - Addr A4 (pin 10) to AddressBus.A4 00035 | - Clock select (pin 11) to VCC (Pull Up) 00036 | - Clock in/out (pin 12) to Not Connected 00037 | - Write (pin 13) to ControlBus.WR 00038 | - CE (Pin 14) to EnableBus.CSDISP 00039 | - VDD 5V (Pin 15) 00040 | - GND (supply) (Pin 16) 00041 | - TST (Pin 16) NC 00042 | - GND (logic) (Pin 18) 00043 | - Read (pin 19) to ControlBus.RD 00044 | - Data D0 (pin 20) to Databus.D0 00045 | - Data D1 (pin 21) to Databus.D1 00046 | - Data D2 (pin 25) to Databus.D2 00047 | - Data D3 (pin 26) to Databus.D3 00048 | - Data D4 (pin 27) to Databus.D4 00049 | - Data D5 (pin 28) to Databus.D5 00050 | - Data D6 (pin 29) to Databus.D6 00051 | - Data D7 (pin 30) to Databus.D7 00052 | 00053 | The peripheral is connected to the following pins: 00054 | HDSP211X 00055 | - Reset (pin 1) to EnableBus.RESET 00056 | - Flash (pin 2) to AddressBus.A5 00057 | - Addr A0 (pin 3) to AddressBus.A0 00058 | - Addr A1 (pin 4) to AddressBus.A1 00059 | - Addr A2 (pin 5) to AddressBus.A2 00060 | - Addr A3 (pin 6) to AddressBus.A3 00061 | - Addr A4 (pin 10) to AddressBus.A4 00062 | - Clock select (pin 11) to VCC (Pull Up) 00063 | - Clock in/out (pin 12) to Not Connected 00064 | - Write (pin 13) to ControlBus.WR 00065 | - VDD 5V (Pin 14) 00066 | - GND (supply) (Pin 15) 00067 | - GND (logic) (Pin 16) 00068 | - CE (Pin 17) to EnableBus.CSDISP 00069 | - Read (pin 18) to ControlBus.RD 00070 | - Data D0 (pin 19) to Databus.D0 00071 | - Data D1 (pin 20) to Databus.D1 00072 | - Data D2 (pin 23) to Databus.D2 00073 | - Data D3 (pin 24) to Databus.D3 00074 | - Data D4 (pin 25) to Databus.D4 00075 | - Data D5 (pin 26) to Databus.D5 00076 | - Data D6 (pin 27) to Databus.D6 00077 | - Data D7 (pin 28) to Databus.D7 00078 | 00079 | Details: All signals to the HDSP253X are pulled up by 10K resistors. 00080 | The device must be reset by pulsing Reset low with Chip Enable 00081 | set high. Other signals are don't cares during a reset. This 00082 | firmware meets these conditions, as long as the pullups are 00083 | correctly installed. 00084 | 00085 | Connecting the clock select and in/out lines to the CPU is optional, 00086 | and may be used for experimentation. 00087 | If using one display, the clock select should normally be pulled 00088 | up high, which results in the clock signal being an output. 00089 | This driver software does not currently control these signals. 00090 | 00091 | If using more than one display, the driver software will 00092 | require modification and extension. Multiple displays should 00093 | have reset, data, address, flash and read/write lines paralleled. 00094 | Each display requires a unique Chip Enable input, and the 00095 | driver software will need to select which display to access. 00096 | The first display should have clock select high, and its clock 00097 | output connected to the clock inputs on all the other displays; 00098 | these should have clock select low to input the clock signal. 00099 | 00100 | Calls to wait_ms() are used to meet the display timing specs 00101 | may need to be modified at higher CPU speeds. 00102 | 00103 | 00104 | Legalese: This software is FREEWARE, and you can adapt it for any 00105 | purpose whatsoever. I cannot be held responsible for any 00106 | loss, injury, damage or death caused by the use of this 00107 | software. 00108 | 00109 \*---------------------------------------------------------------------------*/ 00110 00111 //Useful stuff to simplify porting of some third party software 00112 #include <stdarg.h> 00113 //#include "Utils.h" 00114 00115 00116 /*****************************************************************************/ 00117 /********************* DEFINITIONS FOR HDSP253X DISPLAY ********************/ 00118 /*****************************************************************************/ 00119 00120 // Specific delays for display operation, assuming internal clocking 00121 // This may need to be lengthened if a significantly slower external clock is used 00122 #define HDSP253X_1TCY_WAIT_MS 1 00123 //#define HDSP253X_1TCY_WAIT_MS 10 00124 #define HDSP253X_RST_CLR_DELAY_MS 2 // delay AFTER issuing reset or clear 00125 #define HDSP253X_SELFTEST_WAIT_MS 6000 // duration of self test operation 00126 00127 // address values and masks for HDSP253X display access 00128 #define HDSP253X_ADDR_FLASH_BASE 0x00 00129 #define HDSP253X_ADDR_UDC_ADDRESS 0x20 00130 #define HDSP253X_ADDR_UDC_ROW_BASE 0x28 00131 #define HDSP253X_ADDR_CTRL_WORD 0x30 00132 #define HDSP253X_ADDR_CHAR_BASE 0x38 00133 // minimises address line power consumption through pullups 00134 #define HDSP253X_ADDR_LOW_POWER 0x3F 00135 00136 // control word masks for HDSP253X display 00137 #define HDSP253X_CTRL_BRIGHT_MASK 0x07 00138 #define HDSP253X_CTRL_FLASH_MASK 0x08 00139 #define HDSP253X_CTRL_BLINK_MASK 0x10 00140 #define HDSP253X_CTRL_STRESULT_MASK 0x20 00141 #define HDSP253X_CTRL_SELFTEST_MASK 0x40 00142 #define HDSP253X_CTRL_CLEAR_MASK 0x80 00143 00144 // Masks for register read, Bit 7 not readable in the target hardware 00145 #define HDSP253X_CTRL_MASK 0x7F 00146 00147 00148 // display brightness definitions, indicating percentage brightness 00149 #define HDSP253X_BRIGHT_100 0x00 00150 #define HDSP253X_BRIGHT_80 0x01 00151 #define HDSP253X_BRIGHT_53 0x02 00152 #define HDSP253X_BRIGHT_40 0x03 00153 #define HDSP253X_BRIGHT_27 0x04 00154 #define HDSP253X_BRIGHT_20 0x05 00155 #define HDSP253X_BRIGHT_13 0x06 00156 #define HDSP253X_BRIGHT_0 0x07 00157 00158 // miscellaneous definitions for HDSP253X display 00159 #define HDSP253X_NUM_CHARS 8 00160 #define HDSP253X_CHAR_MASK 0x7F 00161 #define HDSP253X_UDC_SEL 0x80 00162 #define HDSP253X_UDC_MASK 0x0F 00163 #define HDSP253X_ASCII_UDC_CHARS 0x80 00164 00165 // default display brightness 00166 #define HDSP253X_DEF_DISPLAY_BRIGHT HDSP253X_BRIGHT_100 00167 00168 00169 /** Create an HDSP253X_Display object connected to the proper busses 00170 * 00171 * @param PCF8574_DataBus data databus to connect to 00172 * @param PCF8574_AddressBus address addressbus to connect to 00173 * @param PCF8574_EnableBus enable enablebus to connect to 00174 * @param MBED_ControlBus control controlbus to connect to 00175 */ 00176 class HDSP253X_Display { 00177 public: 00178 HDSP253X_Display(PCF8574_DataBus &databus, PCF8574_AddressBus &addressbus, 00179 PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus); 00180 void cls(); 00181 void putc(char disp_char); 00182 // char getc(); 00183 00184 void printf (char * format, ...); 00185 void locate(uint8_t column); 00186 void define_user_char(uint8_t udc_char_num, uint8_t row_data_1, uint8_t row_data_2, 00187 uint8_t row_data_3, uint8_t row_data_4, uint8_t row_data_5, 00188 uint8_t row_data_6, uint8_t row_data_7); 00189 void putudc(char udc_char_num); 00190 00191 void set_char_flash_state(bool flash_state, uint8_t char_pos); 00192 void set_all_flash_states(uint8_t flash_bits); 00193 void set_brightness(uint8_t brightness); 00194 void set_blink_mode(bool enable); 00195 void set_flash_mode(bool enable); 00196 void reset(); 00197 void start_self_test(); 00198 bool finish_self_test(); 00199 00200 protected: 00201 PCF8574_DataBus &_databus; 00202 PCF8574_AddressBus &_addressbus; 00203 PCF8574_EnableBus &_enablebus; 00204 MBED_ControlBus &_controlbus; 00205 00206 // int _row; 00207 int _column; 00208 void _write(uint8_t address, uint8_t data); 00209 uint8_t _read(uint8_t address); 00210 void _init(); 00211 // void _display_ascii_char(char ascii_char, uint8_t char_pos); 00212 // void _display_udc_char(char udc_char, uint8_t char_pos); 00213 // void _display_part_string(const char *disp_string, uint8_t start_pos, uint8_t end_pos); 00214 // void _display_fixed_string(const char *disp_string, uint8_t start_pos); 00215 00216 }; 00217 00218 00219 #endif 00220 /*****************************************************************************/ 00221 /****************************** END OF FILE ********************************/ 00222 /*****************************************************************************/ 00223
Generated on Wed Jul 13 2022 06:43:48 by 1.7.2