A program to measure the temperature using the Max6675 board. The temperature is shown on 8x8 Max7219 matrix display and it is saved on SD as well.
Dependencies: MAX7219 SDFileSystem mbed
Fork of MAXREFDES99_demo by
The program measures the temperature using the Max6675 board designed for Arduino. The temperature is shown on Max7219 8x8 matrix display (designed for Arduino as well) as text marque from right to left. The fonf size is 5x7 so the last row is used to show some info:
- All leds off: Normal temperature measuring - Leds shifting: Saving on SD card - Leds blinking: SD card missing or damaged
The Blue "user button" is used to save measured temperature on SD card. First click start saving, the second stop the process. Together the temperature is saved also the time. The time is reset when the process start. Connecting the USB to PC it's possible to see instant temperature and all saved data on SD.
Diff: main.cpp
- Revision:
- 8:a6a0c9e280ae
- Parent:
- 7:4b81ed6da6ab
- Child:
- 12:1bd4a9f09a8d
--- a/main.cpp Thu Apr 28 08:46:24 2016 +0000 +++ b/main.cpp Tue May 24 08:40:07 2016 +0000 @@ -29,8 +29,8 @@ * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. **********************************************************************/ +#include "maxrefdes99.h" -#include "maxrefdes99.h" int main(void) { @@ -38,11 +38,11 @@ //struct for holding MAX7219 configuration data max7219_configuration_t display_config; - + //configuration data display_config.decode_mode = 0; //no BCD decode - display_config.intensity = 0x0F; //max intensity - display_config.scan_limit = 0x07; //scan all digits + display_config.intensity = Max7219::MAX7219_INTENSITY_F; //max intensity + display_config.scan_limit = Max7219::MAX7219_SCAN_8; //scan all digits //set number of MAX7219 devices being used display.set_num_devices(4); @@ -66,128 +66,91 @@ switch(user_input) { - - case 1: - printf("\n 0: For 5x7 font"); - printf("\n 1: For 16x16 Aerial bold font"); - printf("\n 2: For 16x16 Manual font"); - user_font = get_user_input("\nPlease select font: ", 2); - if((user_font ==1)||(user_font ==2)) - printf("\nNote:Position option works only for 5x7 font\n"); - break; - + case 1: + printf("\n 0: For 5x7 font"); + printf("\n 1: For 16x16 Aerial bold font"); + printf("\n 2: For 16x16 Manual font"); + user_font = get_user_input("\nPlease select font: ", 2); + if((user_font == 1) || (user_font == 2)) + printf("\nNote:Position option works only for 5x7 font\n"); + break; case 2: - - user_input = get_user_input("\nPlease enter a value from 0 to 15: ", 15); - - printf("\nUpdating display configuration...\n"); - - display_config.intensity = user_input; - - display.init_display(display_config); - - //make sure is good for next loop - user_input = 0; - - break; - - case 3: - - if(user_font==0) - user_input = get_user_input("\nPlease enter which position, 1 to 32: ", 32); - - user_char = get_user_char("\nPlease enter an ASCII character from '0' (zero) to 'z' (0x7A): "); - - if(user_font==0) - print_char(&display, user_input, user_char); - else if(user_font>=1) - print_char_16x16(&display, 0, user_char,user_font); - - //make sure is good for next loop - user_input = 0; - - break; - + user_input = get_user_input("\nPlease enter a value from 0 to 15: ", 15); + printf("\nUpdating display configuration...\n"); + display_config.intensity = user_input; + display.init_display(display_config); + //make sure is good for next loop + user_input = 0; + break; + case 3: + if(user_font == 0) + user_input = get_user_input("\nPlease enter which position, 1 to 32: ", 32); + user_char = get_user_char("\nPlease enter an ASCII character from '0' (zero) to 'z' (0x7A): "); + if(user_font == 0) + print_char(&display, user_input, user_char); + else if(user_font >= 1) + print_char_16x16(&display, 0, user_char, user_font); + //make sure is good for next loop + user_input = 0; + break; case 4: - - if(user_font==0) - user_input = get_user_input("\nPlease enter which position 1 to 32: ", 32); - - p_str = get_user_string("\nPlease enter a string less than 24 characters: "); - - if(user_font==0) - print_string(&display, user_input, p_str); - else if(user_font>=1) - print_string_16x16(&display,p_str,user_font); - - //make sure is good for next loop - user_input = 0; - - break; - + if(user_font == 0) + user_input = get_user_input("\nPlease enter which position 1 to 32: ", 32); + p_str = get_user_string("\nPlease enter a string less than 24 characters: "); + if(user_font == 0) + print_string(&display, user_input, p_str); + else if(user_font >=1) + print_string_16x16(&display, p_str, user_font); + //make sure is good for next loop + user_input = 0; + break; case 5: - - if(user_font==0) - user_input = get_user_input("\nPlease enter number of shifts, 1 to 32: ", 32); - else if(user_font>=1) - user_input = get_user_input("\nPlease enter number of shifts, 1 to 96: ", 96); - - shift_right = get_user_input("\nWhich direction? 0 for left, 1 for right: ", 1); - - if(shift_right) - { - printf("\nShifting Display Right %d positions\n", user_input); - if(user_font==0) - shift_display_right(&display, user_input, 100); - else if(user_font>=1) - shift_display_right_16x16(&display, user_input, 100); - } - else - { - printf("\nShifting Display Left %d positions\n", user_input); + if(user_font == 0) + user_input = get_user_input("\nPlease enter number of shifts, 1 to 32: ", 32); + else if(user_font >= 1) + user_input = get_user_input("\nPlease enter number of shifts, 1 to 96: ", 96); + shift_right = get_user_input("\nWhich direction? 0 for left, 1 for right: ", 1); + if(shift_right) + { + printf("\nShifting Display Right %d positions\n", user_input); + if(user_font == 0) + shift_display_right(&display, user_input, 100); + else if(user_font >= 1) + shift_display_right_16x16(&display, user_input, 100); + } + else + { + printf("\nShifting Display Left %d positions\n", user_input); + if(user_font == 0) + shift_display_left(&display, user_input, 100); + else if(user_font >= 1) + shift_display_left_16x16(&display, user_input, 100); + } + break; + case 6: + all_off(&display); + break; + case 7: + printf("\nRunning Demo\n"); if(user_font==0) - shift_display_left(&display, user_input, 100); - else if(user_font>=1) - shift_display_left_16x16(&display, user_input, 100); - - } - - break; - - case 6: - - all_off(&display); - - break; - - case 7: - - printf("\nRunning Demo\n"); - if(user_font==0) - demo(&display, display_config, false); - else if(user_font>=1) - demo_16x16(&display, display_config, user_font,false); - - break; - + demo(&display, display_config, false); + else if(user_font >= 1) + demo_16x16(&display, display_config, user_font, false); + break; case 8: - - //blocking case, endless loop - shift_right = get_user_input("\nWhich direction? 0 for left, 1 for right: ", 1); - if(user_font==0) - endless_scroll_display(&display, shift_right); - else if(user_font>=1) - endless_scroll_display_16x16(&display, shift_right); - - break; - + //blocking case, endless loop + shift_right = get_user_input("\nWhich direction? 0 for left, 1 for right: ", 1); + if(user_font == 0) + endless_scroll_display(&display, shift_right); + else if(user_font >= 1) + endless_scroll_display_16x16(&display, shift_right); + break; case 9: - printf("\nEnding Program\n"); - break; - + printf("\nEnding Program\n"); + break; default: - printf("\nInvalid entry, please try again\n"); - break; + printf("\nInvalid entry, please try again\n"); + break; } } return 0;