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 Maxim Integrated

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.

main.cpp

Committer:
j3
Date:
2016-01-12
Revision:
0:6b0161c3e440
Child:
3:41bdbc9b3cec

File content as of revision 0:6b0161c3e440:

/***********************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
**********************************************************************/


#include "maxrefdes99.h"


int main(void)
{
    Max7219 display(D11, D12, D13, D10);
    
    //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
    
    //set number of MAX7219 devices being used
    display.set_num_devices(4);
    
    //config display 
    display.init_display(display_config);
    
    //ensure all data registers are 0
    display.display_all_off();
    
    display.enable_display();
    
    uint32_t user_input = 0; //
    uint32_t shift_right;
    char user_char;
    char *p_str;
    
    while(user_input != 9)
    {
        user_input = print_menu();
 
        switch(user_input) 
        {
            case 1:
            
                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 2:
            
                user_input = get_user_input("\nPlease enter which position, 1 to 32: ", 32);
                
                user_char = get_user_char("\nPlease enter an ASCII character from 'space' (0x20), to '~' (0x7E): ");
                
                print_char(&display, user_input, user_char);
                
                //make sure is good for next loop
                user_input = 0;
                
            break;
            
            case 3: 
            
                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: ");
                
                print_string(&display, user_input, p_str);

                //make sure is good for next loop
                user_input = 0;
                
            break;
            
            case 4:
            
                user_input = get_user_input("\nPlease enter number of shifts, 1 to 32: ", 32);
                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);
                    shift_display_right(&display, user_input, 100);
                }
                else
                {
                    printf("\nShifting Display Left %d positions\n", user_input);
                    shift_display_left(&display, user_input, 100);
                }
                
            break;
 
            case 5:
            
                all_off(&display);
                
            break;
 
            case 6:
            
                printf("\nRunning Demo\n");
                demo(&display, display_config, false);
                
            break;
 
            case 7:
            
                printf("\nEntering Endless Loop\n");
                demo(&display, display_config, true);
                
            break;
            
            case 8:
                
                //blocking case, endless loop
                shift_right = get_user_input("\nWhich direction? 0 for left, 1 for right.: ", 1);
                endless_scroll_display(&display, shift_right);
                
            break;
            
            case 9:
            
                printf("\nEnding Program\n");
                
            break;
 
            default:
                printf("\nInvalid entry, please try again\n");
            break;
        }
    }
    
    return 0;
}