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.
Fork of OSL10564_74HC595 by
7segLed_HC595.h
00001 /* 00002 * Mbed Library / Akizuki 7-segment LED driver [OSL10564-74HC595-x] 00003 * http://akizukidenshi.com/catalog/g/gM-12643/ 00004 * 00005 * Copyright (c) 2018 Kenji Arai / JH1PJL 00006 * http://www.page.sannet.ne.jp/kenjia/index.html 00007 * http://mbed.org/users/kenjiArai/ 00008 * Created: January 7th, 2018 00009 * Revised: January 22nd, 2018 00010 */ 00011 00012 #ifndef SEVENSEG_LED_DRVR_H 00013 #define SEVENSEG_LED_DRVR_H 00014 00015 #include "mbed.h" 00016 00017 #define BUFFER_SIZE 32 00018 00019 //extern Serial pc; // only for dubug 00020 00021 /** 00022 * @code 00023 * #include "mbed.h" 00024 * #include "7segLed_HC595.h" 00025 * 00026 * // case for Nucleo-F446RE, F411RE, F401RE 00027 * // SPI MOSI, SCLK,port/out,PWM, num of digits 00028 * SevenSegLed led_7segs(D4, D3, D5, D2, 6); 00029 * 00030 * int main() { 00031 * int32_t count = 123456U; 00032 * while(true) { 00033 * led_7segs = count++; 00034 * wait(0.1f); 00035 * } 00036 * } 00037 * @endcode 00038 */ 00039 00040 class SevenSegLed 00041 { 00042 public: 00043 /** 7segments LED driver with 74HC595 (SER, SRCLK, RCLK, /OE) 00044 * @param sdo (->SER), sclk (->SRCLK), latch (->RCLK), bright (->/OE) 00045 * @param sdo must be SPI MOSI and sclk must be same SPI SCLK 00046 * @param latch is any output port 00047 * @param bright must be PwmOut port 00048 * @param num_of_digit -> # of 7seg LED's 00049 */ 00050 SevenSegLed(PinName sdo, PinName sclk, PinName latch, PinName bright, 00051 uint8_t num_of_digit); 00052 00053 /** Set data into 7seg LED's 00054 * @param unsigned data (overflow may occur depend on number of LEDs) 00055 * @return none 00056 */ 00057 void put_num(int32_t dt); 00058 00059 SevenSegLed & operator= (int value) { 00060 put_num(value); 00061 return *this; 00062 } 00063 00064 /** Set ascii number into 7seg LED's 00065 * @param ASCII data 00066 * @return none 00067 */ 00068 void put_ascii(const char *data); 00069 00070 /** Set ascii character strings into 7seg LED's 00071 * @param all ASCII character 00072 * @return none 00073 */ 00074 void put_strings(const char *data); 00075 00076 /** Set raw data into 7seg LED's 00077 * @param Raw data (Segment element) 00078 * @return none 00079 */ 00080 void put_raw(uint8_t *data); 00081 00082 /** Set dot into 7seg LED's 00083 * @param position (1= LSB, 2=2nd, 4=3rd, 8=4th, 16, 32, 64 ----) 00084 * @return none 00085 */ 00086 void put_dot(uint16_t position); 00087 void clear_all_dot(void); 00088 00089 /** Set Brightness 00090 * @param britness max(1.0f) and min = all LED off(0.0f) 00091 * @return none 00092 */ 00093 void brightness(float bright); 00094 00095 /** Set Zero Suppress (defalt OFF) 00096 * @param mode=true -> zero suppress ON, mode = false -> OFF 00097 * @return none 00098 */ 00099 void zero_suppress(bool mode); 00100 00101 /** Set clock frequency 00102 * @param clock frequency (default 1000000Hz(1MHz)) 00103 * @return none 00104 */ 00105 void frequency(int32_t freq); 00106 00107 protected: 00108 SPI spi_; 00109 DigitalOut latch_; 00110 PwmOut pwm_; 00111 00112 uint8_t buf[BUFFER_SIZE]; 00113 uint8_t seg[BUFFER_SIZE]; 00114 uint8_t num; 00115 uint16_t dot_inf; 00116 uint32_t wrk; 00117 bool zerosuppress; 00118 bool num_mode; 00119 float bright_data; 00120 00121 void seven_seg_n_digt(void); 00122 void set_dot(void); 00123 void spi_out(void); 00124 00125 }; 00126 00127 #endif // SEVENSEG_LED_DRVR_H
Generated on Fri Jul 15 2022 08:51:20 by
1.7.2
