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.
MAX7219 Class Reference
Example: More...
#include <MAX7219.h>
Detailed Description
Example:
include "mbed.h" include "MAX7219.h"
MAX7219 myMAX7219 ( p11, p12, p13, p14, 1000000 ); // MOSI: P11 | MISO: P12 | SCLK: P13 | CS: P14 | FREQ: 1MHz
Ticker newReading; DigitalOut myled1 ( LED1 );
MAX7219::MAX7219_status_t mySPI_status;
bool changeDP_status = false;
Change the state of the DP void readDATA ( void ) { myled1 = 1;
if ( changeDP_status == true ) { DP OFF mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_0, MAX7219::CHARACTER_0, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_1, MAX7219::CHARACTER_1, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_2, MAX7219::CHARACTER_2, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_3, MAX7219::CHARACTER_3, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_4, MAX7219::CHARACTER_4, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_5, MAX7219::CHARACTER_5, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_6, MAX7219::CHARACTER_6, MAX7219::DP_DISABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_7, MAX7219::CHARACTER_7, MAX7219::DP_DISABLED );
changeDP_status = false; } else { DP ON mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_0, MAX7219::CHARACTER_0, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_1, MAX7219::CHARACTER_1, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_2, MAX7219::CHARACTER_2, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_3, MAX7219::CHARACTER_3, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_4, MAX7219::CHARACTER_4, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_5, MAX7219::CHARACTER_5, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_6, MAX7219::CHARACTER_6, MAX7219::DP_ENABLED ); wait_us ( 10 ); mySPI_status = myMAX7219.MAX7219_SetDigit ( MAX7219::SET_DIGIT_7, MAX7219::CHARACTER_7, MAX7219::DP_ENABLED );
changeDP_status = true; }
myled1 = 0; }
int main() { uint32_t i = 0;
BCD code ON mySPI_status = myMAX7219.MAX7219_DecodeMode ( MAX7219::DECODE_DIGITS_7_0 ); wait_us ( 10 );
7 digits available mySPI_status = myMAX7219.MAX7219_SetScanLimit( MAX7219::DISPLAY_DIGIT_0_1_2_3_4_5_6_7 ); wait_us ( 10 );
Configure the intensity mySPI_status = myMAX7219.MAX7219_SetIntensity( MAX7219::DUTY_CICLE_9_32 ); wait_us ( 10 );
Clear all the digits for ( i = MAX7219::SET_DIGIT_0; i <= MAX7219::SET_DIGIT_7; i++ ) { mySPI_status = myMAX7219.MAX7219_SetDigit ( ( MAX7219::MAX7219_digit_t )i, MAX7219::CHARACTER_BLANK, MAX7219::DP_DISABLED ); wait_us ( 10 ); }
Test Mode Enabled: All displays ON mySPI_status = myMAX7219.MAX7219_DisplayTest ( MAX7219::DISPLAY_TEST_MODE ); wait_ms ( 2500 );
Test Mode Disabled mySPI_status = myMAX7219.MAX7219_DisplayTest ( MAX7219::DISPLAY_NORMAL_OPERATION ); wait_us ( 10 );
Device in normal operation mode mySPI_status = myMAX7219.MAX7219_Mode ( MAX7219::NORMAL_OPERATION );
newReading.attach( &readDATA, 1 ); // the address of the function to be attached ( readDATA ) and the interval ( 1s )
Let the callbacks take care of everything while(1) { sleep(); } }
Library for the MAX7219 Serially Interfaced, 8-Digit LED Display Drivers.
Definition at line 138 of file MAX7219.h.
Member Enumeration Documentation
| enum MAX7219_code_b_dp_t |
| enum MAX7219_digit_t |
Intensity Register Format.
- Enumerator:
REGISTER ADDRESS MAP.
Scan-Limit Register Format.
- Enumerator:
| enum MAX7219_status_t |
Constructor & Destructor Documentation
| MAX7219 | ( | PinName | mosi, |
| PinName | miso, | ||
| PinName | sclk, | ||
| PinName | cs, | ||
| uint32_t | freq | ||
| ) |
Create an MAX7219 object connected to the specified SPI pins.
- Parameters:
-
mosi SPI Master Output Slave Input miso SPI Master Input Slave Output sclk SPI clock cs SPI Chip Select freq SPI frequency in Hz.
Serially Interfaced, 8-Digit LED Display Drivers. Header file.
- Returns:
- NA
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN.
- Warning:
- NaN
- Precondition:
- This code belongs to AqueronteBlog ( http://unbarquero.blogspot.com ).
Definition at line 20 of file MAX7219.cpp.
| ~MAX7219 | ( | ) |
Delete MAX7219 object.
Definition at line 28 of file MAX7219.cpp.
Member Function Documentation
| MAX7219::MAX7219_status_t MAX7219_DecodeMode | ( | MAX7219_decode_mode_reg_t | myMAX7219DecodeMode ) |
It selects the decode mode.
MAX7219_DecodeMode ( MAX7219_decode_mode_reg_t )
It enables and configures the decode-mode or turns it off.
- Parameters:
-
[in] myMAX7219DecodeMode,: Decode-mode option. [out] NaN.
- Returns:
- Status of MAX7219_DecodeMode.
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 135 of file MAX7219.cpp.
| MAX7219::MAX7219_status_t MAX7219_DisplayTest | ( | MAX7219_display_test_reg_t | myMAX7219DisplayTestMode ) |
It enables all the display or leaves the device in normal operation.
MAX7219_DisplayTest ( MAX7219_display_test_reg_t )
It turns all the LEDs on ( Test mode enabled ) or normal operation.
- Parameters:
-
[in] myMAX7219DisplayTestMode,: Mode: Test or Normal operation. [out] NaN.
- Returns:
- Status of MAX7219_DisplayTest.
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 93 of file MAX7219.cpp.
| MAX7219::MAX7219_status_t MAX7219_Mode | ( | MAX7219_shutdown_reg_t | myMAX7219mode ) |
It puts the device in shutdown/normal operation mode.
MAX7219_Mode ( MAX7219_shutdown_reg_t )
It puts the device in shutdown mode.
- Parameters:
-
[in] myMAX7219mode,: Shutdown or Normal operation mode. [out] NaN.
- Returns:
- Status of MAX7219_Mode.
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 53 of file MAX7219.cpp.
| MAX7219::MAX7219_status_t MAX7219_SetDigit | ( | MAX7219_digit_t | myMAX7219Digit, |
| MAX7219_code_b_font_reg_t | myCharacter, | ||
| MAX7219_code_b_dp_t | myDP_status | ||
| ) |
It sets a new value on the chosen digit.
MAX7219_SetDigit ( MAX7219_digit_t , MAX7219_code_b_font_reg_t , MAX7219_code_b_dp_t )
It sets the digit to be written and its value.
- Parameters:
-
[in] myMAX7219Digit,: Digit to be written. [in] myCharacter,: The current value. [in] myDP_status,: DP enabled/disabled. [out] NaN.
- Returns:
- Status of MAX7219_SetDigit.
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 263 of file MAX7219.cpp.
| MAX7219::MAX7219_status_t MAX7219_SetIntensity | ( | MAX7219_intensity_reg_t | myMAX7219Intensity ) |
It sets the intensity.
MAX7219_SetIntensity ( MAX7219_intensity_reg_t )
It configures the intensity of the device.
- Parameters:
-
[in] myMAX7219Intensity,: Intensity option. [out] NaN.
- Returns:
- Status of MAX7219_SetIntensity.
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 177 of file MAX7219.cpp.
| MAX7219::MAX7219_status_t MAX7219_SetScanLimit | ( | MAX7219_scan_limit_reg_t | myMAX7219ScanLimit ) |
It sets the scan limit.
MAX7219_SetScanLimit ( MAX7219_scan_limit_reg_t )
It configures duty cycle of the device.
- Parameters:
-
[in] MAX7219_scan_limit_reg_t,: Duty cycle option. [out] NaN.
- Returns:
- Status of MAX7219_SetScanLimit.
- Date:
- 9/October/2017
- Version:
- 9/October/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 219 of file MAX7219.cpp.
Generated on Sun Aug 21 2022 18:15:08 by
1.7.2