Change to examples so they also builds
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
# MAX7456
|
||||
A library for interfacing with MAX7456 OSD chip originally created by people at http://theboredengineers.com/2012/12/a-max7456-library-for-arduino/.
|
||||
|
||||
This library should be compatible with Arduino IDE 1.6.6.
|
||||
|
||||
Updated to make it a bit more modern added PlatformIO support and collected various fonts from around the web.
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include <SPI.h>
|
||||
#include <max7456.h>
|
||||
#include <MAX7456.h>
|
||||
|
||||
#define redLed 3
|
||||
#define greenLed 4
|
||||
|
||||
Max7456 osd;
|
||||
MAX7456 osd;
|
||||
unsigned long counter = 0;
|
||||
byte tab[]={0xC8,0xC9};
|
||||
|
||||
@ -12,18 +12,18 @@ void setup()
|
||||
{
|
||||
SPI.begin();
|
||||
|
||||
osd.init(10);
|
||||
osd.init(6);
|
||||
osd.setDisplayOffsets(60,18);
|
||||
osd.setBlinkParams(_8fields, _BT_BT);
|
||||
|
||||
osd.activateOSD();
|
||||
osd.printMax7456Char(0x01,0,1);
|
||||
osd.printMAX7456Char(0x01,0,1);
|
||||
osd.print("Hello world :)",1,3);
|
||||
osd.print("Current Arduino time :",1,4);
|
||||
|
||||
osd.printMax7456Char(0xD1,9,6,true);
|
||||
osd.printMAX7456Char(0xD1,9,6,true);
|
||||
osd.print("00'00\"",10,6);
|
||||
osd.printMax7456Chars(tab,2,12,7);
|
||||
osd.printMAX7456Chars(tab,2,12,7);
|
||||
pinMode(redLed,OUTPUT);
|
||||
pinMode(greenLed,OUTPUT);
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,20 +1,20 @@
|
||||
#include "max7456.h"
|
||||
#include "MAX7456.h"
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::Max7456
|
||||
// Implements MAX7456::MAX7456
|
||||
//-----------------------------------------------------------------------------
|
||||
Max7456::Max7456(byte pinCS)
|
||||
MAX7456::MAX7456(byte pinCS)
|
||||
{
|
||||
this->init(pinCS);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::setBlinkParams
|
||||
// Implements MAX7456::setBlinkParams
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::setBlinkParams(byte blinkBase, byte blinkDC)
|
||||
void MAX7456::setBlinkParams(byte blinkBase, byte blinkDC)
|
||||
{
|
||||
_regVm1.bits.blinkingTime = blinkBase;
|
||||
_regVm1.bits.blinkingDutyCycle = blinkDC;
|
||||
@ -26,9 +26,9 @@ void Max7456::setBlinkParams(byte blinkBase, byte blinkDC)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::setDisplayOffsets
|
||||
// Implements MAX7456::setDisplayOffsets
|
||||
//----------------------------------------------------------------------------
|
||||
void Max7456::setDisplayOffsets(byte horizontal, byte vertical)
|
||||
void MAX7456::setDisplayOffsets(byte horizontal, byte vertical)
|
||||
{
|
||||
|
||||
_regHos.whole = 0;
|
||||
@ -48,17 +48,17 @@ void Max7456::setDisplayOffsets(byte horizontal, byte vertical)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::Max7456
|
||||
// Implements MAX7456::MAX7456
|
||||
//-----------------------------------------------------------------------------
|
||||
Max7456::Max7456()
|
||||
MAX7456::MAX7456()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::sendCharacter
|
||||
// Implements MAX7456::sendCharacter
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::sendCharacter(const charact chara, byte x, byte y)
|
||||
void MAX7456::sendCharacter(const charact chara, byte x, byte y)
|
||||
{
|
||||
byte charAddress;
|
||||
if(y<0)
|
||||
@ -96,9 +96,9 @@ void Max7456::sendCharacter(const charact chara, byte x, byte y)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::getCharacter
|
||||
// Implements MAX7456::getCharacter
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::getCharacter(charact chara, byte x, byte y)
|
||||
void MAX7456::getCharacter(charact chara, byte x, byte y)
|
||||
{
|
||||
byte charAddress;
|
||||
|
||||
@ -136,13 +136,13 @@ void Max7456::getCharacter(charact chara, byte x, byte y)
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::printCharacterToSerial
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::printCharacterToSerial(const charact array, bool img)
|
||||
void MAX7456::printCharacterToSerial(const charact array, bool img)
|
||||
{
|
||||
|
||||
if(img)
|
||||
{
|
||||
CARACT car ;
|
||||
car = Max7456::byteArray2CARACT(array);
|
||||
car = MAX7456::byteArray2CARACT(array);
|
||||
|
||||
Serial.println("------------");
|
||||
for(int i = 0 ; i < 18 ; i++)
|
||||
@ -175,7 +175,7 @@ void Max7456::printCharacterToSerial(const charact array, bool img)
|
||||
}
|
||||
}
|
||||
|
||||
void Max7456::printPixel(byte value)
|
||||
void MAX7456::printPixel(byte value)
|
||||
{
|
||||
switch(value )
|
||||
{
|
||||
@ -193,9 +193,9 @@ void Max7456::printPixel(byte value)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::print
|
||||
// Implements MAX7456::print
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::print(const char string[], byte x, byte y, byte blink,byte inv)
|
||||
void MAX7456::print(const char string[], byte x, byte y, byte blink,byte inv)
|
||||
{
|
||||
char currentChar;
|
||||
byte size;
|
||||
@ -215,26 +215,26 @@ void Max7456::print(const char string[], byte x, byte y, byte blink,byte inv)
|
||||
|
||||
for(byte i = 0 ; i < size ; i++)
|
||||
{
|
||||
chars[i] = Max7456::giveMax7456CharFromAsciiChar(string[i]);
|
||||
chars[i] = MAX7456::giveMAX7456CharFromAsciiChar(string[i]);
|
||||
}
|
||||
|
||||
printMax7456Chars(chars, size, x, y, blink , inv );
|
||||
printMAX7456Chars(chars, size, x, y, blink , inv );
|
||||
free(chars);
|
||||
}
|
||||
|
||||
|
||||
void Max7456::printMax7456Char(const byte address, byte x, byte y, byte blink, byte inv)
|
||||
void MAX7456::printMAX7456Char(const byte address, byte x, byte y, byte blink, byte inv)
|
||||
{
|
||||
byte ad = address;
|
||||
printMax7456Chars(&ad,1,x,y,blink,inv);
|
||||
printMAX7456Chars(&ad,1,x,y,blink,inv);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::printMax7456Chars
|
||||
// Implements MAX7456::printMAX7456Chars
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::printMax7456Chars(byte chars[],byte size,byte x, byte y, byte blink ,byte inv )
|
||||
void MAX7456::printMAX7456Chars(byte chars[],byte size,byte x, byte y, byte blink ,byte inv )
|
||||
{
|
||||
byte currentCharMax7456;
|
||||
byte currentChar;
|
||||
byte posAddressLO;
|
||||
byte posAddressHI;
|
||||
unsigned int posAddress;
|
||||
@ -266,9 +266,9 @@ void Max7456::printMax7456Chars(byte chars[],byte size,byte x, byte y, byte blin
|
||||
|
||||
for(int i = 0; i < size ; i++)
|
||||
{
|
||||
currentCharMax7456 = chars[i];
|
||||
currentChar = chars[i];
|
||||
SPI.transfer(DMDI_ADDRESS_WRITE);
|
||||
SPI.transfer(currentCharMax7456);
|
||||
SPI.transfer(currentChar);
|
||||
|
||||
}
|
||||
|
||||
@ -287,10 +287,10 @@ void Max7456::printMax7456Chars(byte chars[],byte size,byte x, byte y, byte blin
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::print
|
||||
// Implements MAX7456::print
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Max7456::print(double value, byte x, byte y, byte before, byte after, byte blink,byte inv)
|
||||
void MAX7456::print(double value, byte x, byte y, byte before, byte after, byte blink,byte inv)
|
||||
{
|
||||
char *strValue = NULL;
|
||||
|
||||
@ -321,11 +321,12 @@ void Max7456::print(double value, byte x, byte y, byte before, byte after, byte
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::giveMax7456CharFromAsciiChar
|
||||
// Implements MAX7456::giveMAX7456CharFromAsciiChar
|
||||
//-----------------------------------------------------------------------------
|
||||
byte Max7456::giveMax7456CharFromAsciiChar(char ascii)
|
||||
byte MAX7456::giveMAX7456CharFromAsciiChar(char ascii)
|
||||
{
|
||||
#ifdef MAX7456_TABLE_ASCII
|
||||
#error Do not be here
|
||||
if(ascii >= ' ' && ascii <= 'z')
|
||||
return ascii-' ';
|
||||
else
|
||||
@ -337,9 +338,9 @@ byte Max7456::giveMax7456CharFromAsciiChar(char ascii)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::clearScreen
|
||||
// Implements MAX7456::clearScreen
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::clearScreen()
|
||||
void MAX7456::clearScreen()
|
||||
{
|
||||
_regDmm.bits.clearDisplayMemory = 1 ;
|
||||
|
||||
@ -359,9 +360,9 @@ void Max7456::clearScreen()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::init
|
||||
// Implements MAX7456::init
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::init(byte iPinCS)
|
||||
void MAX7456::init(byte iPinCS)
|
||||
{
|
||||
_pinCS = iPinCS;
|
||||
_isActivatedOsd = false;
|
||||
@ -412,9 +413,9 @@ void Max7456::init(byte iPinCS)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::activateOSD
|
||||
// Implements MAX7456::activateOSD
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::activateOSD(bool act)
|
||||
void MAX7456::activateOSD(bool act)
|
||||
{
|
||||
if(_isActivatedOsd != act)
|
||||
{
|
||||
@ -435,9 +436,9 @@ void Max7456::activateOSD(bool act)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::activateExternalVideo
|
||||
// Implements MAX7456::activateExternalVideo
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::activateExternalVideo(bool activExtVid)
|
||||
void MAX7456::activateExternalVideo(bool activExtVid)
|
||||
{
|
||||
if(!activExtVid)
|
||||
_regVm0.bits.synchSelect = 3; //11
|
||||
@ -452,9 +453,9 @@ void Max7456::activateExternalVideo(bool activExtVid)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::CARACT2ByteArray
|
||||
// Implements MAX7456::CARACT2ByteArray
|
||||
//-----------------------------------------------------------------------------
|
||||
byte* Max7456::CARACT2ByteArray(const CARACT car)
|
||||
byte* MAX7456::CARACT2ByteArray(const CARACT car)
|
||||
{
|
||||
byte *array = NULL;
|
||||
array = new charact;
|
||||
@ -466,9 +467,9 @@ byte* Max7456::CARACT2ByteArray(const CARACT car)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::byteArray2CARACT
|
||||
// Implements MAX7456::byteArray2CARACT
|
||||
//-----------------------------------------------------------------------------
|
||||
CARACT Max7456::byteArray2CARACT(const charact array)
|
||||
CARACT MAX7456::byteArray2CARACT(const charact array)
|
||||
{
|
||||
CARACT car;
|
||||
for(int i = 0 ; i < 54 ; i++)
|
||||
@ -479,9 +480,9 @@ CARACT Max7456::byteArray2CARACT(const charact array)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::getCARACFromProgMem
|
||||
// Implements MAX7456::getCARACFromProgMem
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::getCARACFromProgMem(const char *table, byte i, charact car)
|
||||
void MAX7456::getCARACFromProgMem(const char *table, byte i, charact car)
|
||||
{
|
||||
unsigned long index;
|
||||
byte read;
|
||||
@ -494,4 +495,3 @@ void Max7456::getCARACFromProgMem(const char *table, byte i, charact car)
|
||||
car[j] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* max7456.h
|
||||
* MAX7456.h
|
||||
*
|
||||
* Created on: 10 oct. 2012
|
||||
* Author: Benoit
|
||||
@ -10,30 +10,27 @@
|
||||
#define MAX7456_H
|
||||
|
||||
|
||||
//def next only if you changed your table for a non ascii one
|
||||
//def next only if you changed your table for an ascii one
|
||||
//i.e address 0x00 -> ' '
|
||||
//....
|
||||
// address 0x5A -> 'z'
|
||||
// This may be passed on from the compiler if you are using platformio.
|
||||
//#define MAX7456_TABLE_ASCII
|
||||
|
||||
#include "max7456registers.h"
|
||||
#include "MAX7456Registers.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @mainpage Max7456 Arduino library
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example Max7456WriteTable.cpp
|
||||
* @mainpage MAX7456 Arduino library
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @class Max7456
|
||||
* @brief Represents a max7456 device communicating through SPI port
|
||||
* @class MAX7456
|
||||
* @brief Represents a MAX7456 device communicating through SPI port
|
||||
*/
|
||||
class Max7456
|
||||
class MAX7456
|
||||
{
|
||||
public:
|
||||
|
||||
@ -41,23 +38,23 @@ public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
Max7456();
|
||||
MAX7456();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Initialize communications and device
|
||||
* @param pinCS : pin ~CS of the arduino where max7456 is plugged.
|
||||
* @param pinCS : pin ~CS of the arduino where MAX7456 is plugged.
|
||||
*/
|
||||
Max7456(byte pinCS);
|
||||
MAX7456(byte pinCS);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize communications and device
|
||||
* @param pinCS : pin ~CS of the arduino where max7456 is plugged.
|
||||
* @param pinCS : pin ~CS of the arduino where MAX7456 is plugged.
|
||||
* @code
|
||||
* Max7456 osd;
|
||||
* osd.init(9); //Note it's that it's the same than usinge constructor Max7456(byte pinCS).
|
||||
* MAX7456 osd;
|
||||
* osd.init(9); //Note it's that it's the same than usinge constructor MAX7456(byte pinCS).
|
||||
* @endcode
|
||||
*/
|
||||
void init(byte pinCS);
|
||||
@ -163,9 +160,9 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Put some characters in the display memory of max7456.
|
||||
* Put some characters in the display memory of MAX7456.
|
||||
* The characters are given by their address in the
|
||||
* character memory of the max7456.
|
||||
* character memory of the MAX7456.
|
||||
* @param chars : The characters address array to display
|
||||
* @param size : the array size
|
||||
* @param x : the horizontal position of the value on screen
|
||||
@ -174,21 +171,21 @@ public:
|
||||
* @param inv : if 1 then color character will be inverted
|
||||
* @code
|
||||
* char chars[0x04,0x45,0x54]; //the chars addresses array to be send to function.
|
||||
* max.printMax7456Chars(chars,3,x,y);
|
||||
* max.printMAX7456Chars(chars,3,x,y);
|
||||
* @endcode
|
||||
*/
|
||||
void printMax7456Chars(byte chars[],byte size,byte x, byte y, byte blink = 0,byte inv = 0);
|
||||
void printMAX7456Chars(byte chars[],byte size,byte x, byte y, byte blink = 0,byte inv = 0);
|
||||
|
||||
|
||||
/**
|
||||
* Put one character from the character memory in the display memory of max7456
|
||||
* Put one character from the character memory in the display memory of MAX7456
|
||||
* @param address : The address in character memory of the character to be displayed
|
||||
* @param x : the horizontal position of the string on screen
|
||||
* @param y : the vertical position of the string on screen
|
||||
* @param blink : if 1 then character will blink
|
||||
* @param inv : if 1 then color character will be inverted
|
||||
*/
|
||||
void printMax7456Char(const byte address, byte x, byte y, byte blink=0, byte inv=0);
|
||||
void printMAX7456Char(const byte address, byte x, byte y, byte blink=0, byte inv=0);
|
||||
|
||||
/**
|
||||
* Print a character to Serial port
|
||||
@ -229,7 +226,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
byte giveMax7456CharFromAsciiChar(char ascii);
|
||||
byte giveMAX7456CharFromAsciiChar(char ascii);
|
||||
static void printPixel(byte value);
|
||||
|
||||
byte _pinCS;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* max7456Registers.h
|
||||
* MAX7456Registers.h
|
||||
*
|
||||
* Created on: 13 oct. 2012
|
||||
* Author: Benoit
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
/**
|
||||
* @typedef charact
|
||||
* @brief Represents a character as stored in max7456 character memory.
|
||||
* @brief Represents a character as stored in MAX7456 character memory.
|
||||
*/
|
||||
typedef byte charact[54];
|
||||
|
||||
|
Reference in New Issue
Block a user