Compare commits
2 Commits
530fb9c111
...
1e99abecab
Author | SHA1 | Date | |
---|---|---|---|
1e99abecab | |||
1936746a40 |
@ -8,3 +8,4 @@ steps:
|
|||||||
- pip install platformio
|
- pip install platformio
|
||||||
- pio ci --lib src/ examples/HelloWorld --board=pro16MHzatmega328
|
- pio ci --lib src/ examples/HelloWorld --board=pro16MHzatmega328
|
||||||
- pio ci --lib src/ examples/Max7456Write --board=pro16MHzatmega328
|
- pio ci --lib src/ examples/Max7456Write --board=pro16MHzatmega328
|
||||||
|
- pio ci --lib src/ examples/WriteMCM --board=pro16MHzatmega328
|
@ -1,7 +1,6 @@
|
|||||||
# MAX7456
|
# MAX7456
|
||||||
A library for interfacing with MAX7456 OSD chip originally created by people at http://theboredengineers.com/2012/12/a-max7456-library-for-arduino/.
|
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.
|
Updated to make it a bit more modern added PlatformIO support and collected various fonts from around the web.
|
||||||
|
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <max7456.h>
|
#include <MAX7456.h>
|
||||||
|
|
||||||
#define redLed 3
|
#define redLed 3
|
||||||
#define greenLed 4
|
#define greenLed 4
|
||||||
|
|
||||||
Max7456 osd;
|
MAX7456 osd;
|
||||||
unsigned long counter = 0;
|
unsigned long counter = 0;
|
||||||
byte tab[]={0xC8,0xC9};
|
byte tab[]={0xED,0xEE, 0xEF, 0xF3};
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
|
|
||||||
osd.init(10);
|
osd.init(6);
|
||||||
osd.setDisplayOffsets(60,18);
|
osd.setDisplayOffsets(60,18);
|
||||||
osd.setBlinkParams(_8fields, _BT_BT);
|
osd.setBlinkParams(_8fields, _3BT_BT);
|
||||||
|
|
||||||
osd.activateOSD();
|
osd.activateOSD();
|
||||||
osd.printMax7456Char(0x01,0,1);
|
osd.printMAX7456Char(0x12,0,1);
|
||||||
osd.print("Hello world :)",1,3);
|
osd.print("Hello world :)",1,3);
|
||||||
osd.print("Current Arduino time :",1,4);
|
osd.print("Current time :",1,4);
|
||||||
|
|
||||||
osd.printMax7456Char(0xD1,9,6,true);
|
osd.printMAX7456Char(0xFB,9,6,true);
|
||||||
osd.print("00'00\"",10,6);
|
osd.print("00'00\"",10,6);
|
||||||
osd.printMax7456Chars(tab,2,12,7);
|
osd.printMAX7456Chars(tab,sizeof(tab),12,7);
|
||||||
pinMode(redLed,OUTPUT);
|
pinMode(redLed,OUTPUT);
|
||||||
pinMode(greenLed,OUTPUT);
|
pinMode(greenLed,OUTPUT);
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
345
examples/WriteMCM/WriteMCM.ino
Normal file
345
examples/WriteMCM/WriteMCM.ino
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
// Code to copy a MCM font file to the Arduino + Max7456 OSD
|
||||||
|
//
|
||||||
|
// MAX7456_font Sketch
|
||||||
|
// at 9600 baud it take about 3min to download a mcm file
|
||||||
|
// http://www.maxim-ic.com/tools/evkit/index.cfm?EVKit=558
|
||||||
|
// max7456 evaluation kit software
|
||||||
|
|
||||||
|
#define DATAOUT 11//11-MOSI
|
||||||
|
#define DATAIN 12//12-MISO
|
||||||
|
#define SPICLOCK 13//13-sck
|
||||||
|
#define MAX7456SELECT 6 //6
|
||||||
|
#define USBSELECT 10//10-ss
|
||||||
|
#define VSYNC 2// INT0
|
||||||
|
|
||||||
|
//MAX7456 opcodes
|
||||||
|
#define VM0_reg 0x00
|
||||||
|
#define VM1_reg 0x01
|
||||||
|
#define DMM_reg 0x04
|
||||||
|
#define DMAH_reg 0x05
|
||||||
|
#define DMAL_reg 0x06
|
||||||
|
#define DMDI_reg 0x07
|
||||||
|
#define CMM_reg 0x08
|
||||||
|
#define CMAH_reg 0x09
|
||||||
|
#define CMAL_reg 0x0A
|
||||||
|
#define CMDI_reg 0x0B
|
||||||
|
#define STAT_reg 0xA0
|
||||||
|
|
||||||
|
//MAX7456 commands
|
||||||
|
#define CLEAR_display 0x04
|
||||||
|
#define CLEAR_display_vert 0x06
|
||||||
|
#define END_string 0xff
|
||||||
|
#define WRITE_nvr 0xa0
|
||||||
|
// with NTSC
|
||||||
|
#define ENABLE_display 0x08
|
||||||
|
#define ENABLE_display_vert 0x0c
|
||||||
|
#define MAX7456_reset 0x02
|
||||||
|
#define DISABLE_display 0x00
|
||||||
|
|
||||||
|
// with PAL
|
||||||
|
// all VM0_reg commands need bit 6 set
|
||||||
|
//#define ENABLE_display 0x48
|
||||||
|
//#define ENABLE_display_vert 0x4c
|
||||||
|
//#define MAX7456_reset 0x42
|
||||||
|
//#define DISABLE_display 0x40
|
||||||
|
|
||||||
|
#define WHITE_level_80 0x03
|
||||||
|
#define WHITE_level_90 0x02
|
||||||
|
#define WHITE_level_100 0x01
|
||||||
|
#define WHITE_level_120 0x00
|
||||||
|
|
||||||
|
#define MAX_font_rom 0xff
|
||||||
|
#define STATUS_reg_nvr_busy 0x20
|
||||||
|
#define NVM_ram_size 0x36
|
||||||
|
|
||||||
|
// with NTSC
|
||||||
|
#define MAX_screen_rows 0x0d //13
|
||||||
|
|
||||||
|
// with PAL
|
||||||
|
//#define MAX_screen_rows 0x10 //16
|
||||||
|
|
||||||
|
volatile byte screen_buffer[MAX_font_rom];
|
||||||
|
volatile byte character_bitmap[0x40];
|
||||||
|
volatile byte ascii_binary[0x08];
|
||||||
|
|
||||||
|
volatile byte bit_count;
|
||||||
|
volatile byte byte_count;
|
||||||
|
volatile int font_count;
|
||||||
|
volatile int incomingByte;
|
||||||
|
volatile int count;
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
byte spi_junk;
|
||||||
|
int x;
|
||||||
|
Serial.begin(38400);
|
||||||
|
Serial.flush();
|
||||||
|
|
||||||
|
digitalWrite(USBSELECT,HIGH); //disable USB chip
|
||||||
|
|
||||||
|
pinMode(MAX7456SELECT,OUTPUT);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH); //disable device
|
||||||
|
|
||||||
|
pinMode(DATAOUT, OUTPUT);
|
||||||
|
pinMode(DATAIN, INPUT);
|
||||||
|
pinMode(SPICLOCK,OUTPUT);
|
||||||
|
pinMode(VSYNC, INPUT);
|
||||||
|
|
||||||
|
// SPCR = 01010000
|
||||||
|
//interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
|
||||||
|
//sample on leading edge of clk,system clock/4 rate (4 meg)
|
||||||
|
SPCR = (1<<SPE)|(1<<MSTR);
|
||||||
|
spi_junk=SPSR;
|
||||||
|
spi_junk=SPDR;
|
||||||
|
delay(250);
|
||||||
|
|
||||||
|
// force soft reset on Max7456
|
||||||
|
digitalWrite(MAX7456SELECT,LOW);
|
||||||
|
spi_transfer(VM0_reg);
|
||||||
|
spi_transfer(MAX7456_reset);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
// set all rows to same character white level, 90%
|
||||||
|
digitalWrite(MAX7456SELECT,LOW);
|
||||||
|
for (x = 0; x < MAX_screen_rows; x++)
|
||||||
|
{
|
||||||
|
spi_transfer(x + 0x10);
|
||||||
|
spi_transfer(WHITE_level_90);
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure the Max7456 is enabled
|
||||||
|
spi_transfer(VM0_reg);
|
||||||
|
spi_transfer(ENABLE_display);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH);
|
||||||
|
|
||||||
|
incomingByte = 0;
|
||||||
|
count = 0;
|
||||||
|
bit_count = 0;
|
||||||
|
byte_count = 0;
|
||||||
|
font_count = 0;
|
||||||
|
|
||||||
|
//display all 256 internal MAX7456 characters
|
||||||
|
for (x = 0; x < MAX_font_rom; x++)
|
||||||
|
{
|
||||||
|
screen_buffer[x] = x;
|
||||||
|
}
|
||||||
|
count = MAX_font_rom;
|
||||||
|
write_new_screen();
|
||||||
|
|
||||||
|
Serial.println("Ready for text file download");
|
||||||
|
Serial.println("");
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
byte x;
|
||||||
|
|
||||||
|
if (Serial.available() > 0)
|
||||||
|
{
|
||||||
|
// read the incoming byte:
|
||||||
|
incomingByte = Serial.read();
|
||||||
|
|
||||||
|
switch(incomingByte) // parse and decode mcm file
|
||||||
|
{
|
||||||
|
case 0x0d: // carridge return, end of line
|
||||||
|
//Serial.println("cr");
|
||||||
|
if (bit_count == 8 && (ascii_binary[0] == 0x30 || ascii_binary[0] == 0x31))
|
||||||
|
{
|
||||||
|
// turn 8 ascii binary bytes to single byte '01010101' = 0x55
|
||||||
|
// fill in 64 bytes of character data
|
||||||
|
character_bitmap[byte_count] = decode_ascii_binary();
|
||||||
|
byte_count++;
|
||||||
|
bit_count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bit_count = 0;
|
||||||
|
break;
|
||||||
|
case 0x0a: // line feed, ignore
|
||||||
|
//Serial.println("ln");
|
||||||
|
break;
|
||||||
|
case 0x30: // ascii '0'
|
||||||
|
case 0x31: // ascii '1'
|
||||||
|
ascii_binary[bit_count] = incomingByte;
|
||||||
|
bit_count++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have one completed character
|
||||||
|
// write the character to NVM
|
||||||
|
if(byte_count == 64)
|
||||||
|
{
|
||||||
|
write_NVM();
|
||||||
|
byte_count = 0;
|
||||||
|
font_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have burned all 256 characters in NVM
|
||||||
|
if(font_count == 256)
|
||||||
|
{
|
||||||
|
font_count = 0;
|
||||||
|
|
||||||
|
// force soft reset on Max7456
|
||||||
|
digitalWrite(MAX7456SELECT,LOW);
|
||||||
|
spi_transfer(VM0_reg);
|
||||||
|
spi_transfer(MAX7456_reset);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
// display all 256 new internal MAX7456 characters
|
||||||
|
for (x = 0; x < MAX_font_rom; x++)
|
||||||
|
{
|
||||||
|
screen_buffer[x] = x;
|
||||||
|
}
|
||||||
|
count = MAX_font_rom;
|
||||||
|
write_new_screen();
|
||||||
|
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("Done with file download");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
byte spi_transfer(volatile byte data)
|
||||||
|
{
|
||||||
|
SPDR = data; // Start the transmission
|
||||||
|
while (!(SPSR & (1<<SPIF))) // Wait the end of the transmission
|
||||||
|
{
|
||||||
|
};
|
||||||
|
return SPDR; // return the received byte
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
void write_new_screen()
|
||||||
|
{
|
||||||
|
int x, local_count;
|
||||||
|
byte char_address_hi, char_address_lo;
|
||||||
|
byte screen_char;
|
||||||
|
|
||||||
|
local_count = count;
|
||||||
|
|
||||||
|
char_address_hi = 0;
|
||||||
|
char_address_lo = 60; // start on third line
|
||||||
|
//Serial.println("write_new_screen");
|
||||||
|
|
||||||
|
// clear the screen
|
||||||
|
digitalWrite(MAX7456SELECT,LOW);
|
||||||
|
spi_transfer(DMM_reg);
|
||||||
|
spi_transfer(CLEAR_display);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH);
|
||||||
|
|
||||||
|
// disable display
|
||||||
|
digitalWrite(MAX7456SELECT,LOW);
|
||||||
|
spi_transfer(VM0_reg);
|
||||||
|
spi_transfer(DISABLE_display);
|
||||||
|
|
||||||
|
spi_transfer(DMM_reg); //dmm
|
||||||
|
//spi_transfer(0x21); //16 bit trans background
|
||||||
|
spi_transfer(0x01); //16 bit trans w/o background
|
||||||
|
|
||||||
|
spi_transfer(DMAH_reg); // set start address high
|
||||||
|
spi_transfer(char_address_hi);
|
||||||
|
|
||||||
|
spi_transfer(DMAL_reg); // set start address low
|
||||||
|
spi_transfer(char_address_lo);
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
while(local_count) // write out full screen
|
||||||
|
{
|
||||||
|
screen_char = screen_buffer[x];
|
||||||
|
spi_transfer(DMDI_reg);
|
||||||
|
spi_transfer(screen_char);
|
||||||
|
x++;
|
||||||
|
local_count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
spi_transfer(DMDI_reg);
|
||||||
|
spi_transfer(END_string);
|
||||||
|
|
||||||
|
spi_transfer(VM0_reg); // turn on screen next vertical
|
||||||
|
spi_transfer(ENABLE_display_vert);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
byte decode_ascii_binary()
|
||||||
|
{
|
||||||
|
byte ascii_byte;
|
||||||
|
|
||||||
|
ascii_byte = 0;
|
||||||
|
|
||||||
|
if (ascii_binary[0] == 0x31) // ascii '1'
|
||||||
|
ascii_byte = ascii_byte + 128;
|
||||||
|
|
||||||
|
if (ascii_binary[1] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 64;
|
||||||
|
|
||||||
|
if (ascii_binary[2] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 32;
|
||||||
|
|
||||||
|
if (ascii_binary[3] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 16;
|
||||||
|
|
||||||
|
if (ascii_binary[4] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 8;
|
||||||
|
|
||||||
|
if (ascii_binary[5] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 4;
|
||||||
|
|
||||||
|
if (ascii_binary[6] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 2;
|
||||||
|
|
||||||
|
if (ascii_binary[7] == 0x31)
|
||||||
|
ascii_byte = ascii_byte + 1;
|
||||||
|
|
||||||
|
//Serial.print(ascii_byte, HEX);
|
||||||
|
|
||||||
|
return(ascii_byte);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
void write_NVM()
|
||||||
|
{
|
||||||
|
byte x;
|
||||||
|
byte char_address_hi, char_address_lo;
|
||||||
|
byte screen_char;
|
||||||
|
|
||||||
|
char_address_hi = font_count;
|
||||||
|
char_address_lo = 0;
|
||||||
|
//Serial.println("write_new_screen");
|
||||||
|
|
||||||
|
// disable display
|
||||||
|
digitalWrite(MAX7456SELECT,LOW);
|
||||||
|
spi_transfer(VM0_reg);
|
||||||
|
spi_transfer(DISABLE_display);
|
||||||
|
|
||||||
|
spi_transfer(CMAH_reg); // set start address high
|
||||||
|
spi_transfer(char_address_hi);
|
||||||
|
|
||||||
|
for(x = 0; x < NVM_ram_size; x++) // write out 54 (out of 64) bytes of character to shadow ram
|
||||||
|
{
|
||||||
|
screen_char = character_bitmap[x];
|
||||||
|
spi_transfer(CMAL_reg); // set start address low
|
||||||
|
spi_transfer(x);
|
||||||
|
spi_transfer(CMDI_reg);
|
||||||
|
spi_transfer(screen_char);
|
||||||
|
}
|
||||||
|
|
||||||
|
// transfer a 54 bytes from shadow ram to NVM
|
||||||
|
spi_transfer(CMM_reg);
|
||||||
|
spi_transfer(WRITE_nvr);
|
||||||
|
|
||||||
|
// wait until bit 5 in the status register returns to 0 (12ms)
|
||||||
|
while ((spi_transfer(STAT_reg) & STATUS_reg_nvr_busy) != 0x00);
|
||||||
|
|
||||||
|
spi_transfer(VM0_reg); // turn on screen next vertical
|
||||||
|
spi_transfer(ENABLE_display_vert);
|
||||||
|
digitalWrite(MAX7456SELECT,HIGH);
|
||||||
|
}
|
BIN
schematic/Minim_OSD_schematic.jpg
Normal file
BIN
schematic/Minim_OSD_schematic.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 265 KiB |
100
src/max7456.cpp
100
src/max7456.cpp
@ -1,20 +1,20 @@
|
|||||||
#include "max7456.h"
|
#include "MAX7456.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Implements Max7456::Max7456
|
// Implements MAX7456::MAX7456
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Max7456::Max7456(byte pinCS)
|
MAX7456::MAX7456(byte pinCS)
|
||||||
{
|
{
|
||||||
this->init(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.blinkingTime = blinkBase;
|
||||||
_regVm1.bits.blinkingDutyCycle = blinkDC;
|
_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;
|
_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;
|
byte charAddress;
|
||||||
if(y<0)
|
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;
|
byte charAddress;
|
||||||
|
|
||||||
@ -136,13 +136,13 @@ void Max7456::getCharacter(charact chara, byte x, byte y)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Implements Max7456::printCharacterToSerial
|
// Implements Max7456::printCharacterToSerial
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Max7456::printCharacterToSerial(const charact array, bool img)
|
void MAX7456::printCharacterToSerial(const charact array, bool img)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(img)
|
if(img)
|
||||||
{
|
{
|
||||||
CARACT car ;
|
CARACT car ;
|
||||||
car = Max7456::byteArray2CARACT(array);
|
car = MAX7456::byteArray2CARACT(array);
|
||||||
|
|
||||||
Serial.println("------------");
|
Serial.println("------------");
|
||||||
for(int i = 0 ; i < 18 ; i++)
|
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 )
|
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;
|
char currentChar;
|
||||||
byte size;
|
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++)
|
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);
|
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;
|
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 posAddressLO;
|
||||||
byte posAddressHI;
|
byte posAddressHI;
|
||||||
unsigned int posAddress;
|
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++)
|
for(int i = 0; i < size ; i++)
|
||||||
{
|
{
|
||||||
currentCharMax7456 = chars[i];
|
currentChar = chars[i];
|
||||||
SPI.transfer(DMDI_ADDRESS_WRITE);
|
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;
|
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
|
#ifdef MAX7456_TABLE_ASCII
|
||||||
|
#error Do not be here
|
||||||
if(ascii >= ' ' && ascii <= 'z')
|
if(ascii >= ' ' && ascii <= 'z')
|
||||||
return ascii-' ';
|
return ascii-' ';
|
||||||
else
|
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 ;
|
_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;
|
_pinCS = iPinCS;
|
||||||
_isActivatedOsd = false;
|
_isActivatedOsd = false;
|
||||||
@ -399,22 +400,14 @@ void Max7456::init(byte iPinCS)
|
|||||||
|
|
||||||
SPI.transfer(_regVm0.whole);
|
SPI.transfer(_regVm0.whole);
|
||||||
|
|
||||||
|
|
||||||
// digitalWrite(_pinCS,HIGH);
|
|
||||||
//
|
|
||||||
// digitalWrite(_pinCS,LOW);
|
|
||||||
//SPI.transfer(VM1_ADDRESS_WRITE);
|
|
||||||
//SPI.transfer(0x0C);
|
|
||||||
|
|
||||||
digitalWrite(_pinCS,HIGH);
|
digitalWrite(_pinCS,HIGH);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Implements Max7456::activateOSD
|
// Implements MAX7456::activateOSD
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Max7456::activateOSD(bool act)
|
void MAX7456::activateOSD(bool act)
|
||||||
{
|
{
|
||||||
if(_isActivatedOsd != act)
|
if(_isActivatedOsd != act)
|
||||||
{
|
{
|
||||||
@ -435,9 +428,9 @@ void Max7456::activateOSD(bool act)
|
|||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Implements Max7456::activateExternalVideo
|
// Implements MAX7456::activateExternalVideo
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Max7456::activateExternalVideo(bool activExtVid)
|
void MAX7456::activateExternalVideo(bool activExtVid)
|
||||||
{
|
{
|
||||||
if(!activExtVid)
|
if(!activExtVid)
|
||||||
_regVm0.bits.synchSelect = 3; //11
|
_regVm0.bits.synchSelect = 3; //11
|
||||||
@ -452,9 +445,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;
|
byte *array = NULL;
|
||||||
array = new charact;
|
array = new charact;
|
||||||
@ -466,9 +459,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;
|
CARACT car;
|
||||||
for(int i = 0 ; i < 54 ; i++)
|
for(int i = 0 ; i < 54 ; i++)
|
||||||
@ -479,9 +472,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;
|
unsigned long index;
|
||||||
byte read;
|
byte read;
|
||||||
@ -494,4 +487,3 @@ void Max7456::getCARACFromProgMem(const char *table, byte i, charact car)
|
|||||||
car[j] = 0xff;
|
car[j] = 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* max7456.h
|
* MAX7456.h
|
||||||
*
|
*
|
||||||
* Created on: 10 oct. 2012
|
* Created on: 10 oct. 2012
|
||||||
* Author: Benoit
|
* Author: Benoit
|
||||||
@ -10,30 +10,27 @@
|
|||||||
#define MAX7456_H
|
#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 -> ' '
|
//i.e address 0x00 -> ' '
|
||||||
//....
|
//....
|
||||||
// address 0x5A -> 'z'
|
// address 0x5A -> 'z'
|
||||||
|
// This may be passed on from the compiler if you are using platformio.
|
||||||
//#define MAX7456_TABLE_ASCII
|
//#define MAX7456_TABLE_ASCII
|
||||||
|
|
||||||
#include "max7456registers.h"
|
#include "MAX7456Registers.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mainpage Max7456 Arduino library
|
* @mainpage MAX7456 Arduino library
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @example Max7456WriteTable.cpp
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Max7456
|
* @class MAX7456
|
||||||
* @brief Represents a max7456 device communicating through SPI port
|
* @brief Represents a MAX7456 device communicating through SPI port
|
||||||
*/
|
*/
|
||||||
class Max7456
|
class MAX7456
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -41,23 +38,23 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
Max7456();
|
MAX7456();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Initialize communications and device
|
* 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
|
* 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
|
* @code
|
||||||
* Max7456 osd;
|
* MAX7456 osd;
|
||||||
* osd.init(9); //Note it's that it's the same than usinge constructor Max7456(byte pinCS).
|
* osd.init(9); //Note it's that it's the same than usinge constructor MAX7456(byte pinCS).
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
void init(byte pinCS);
|
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
|
* 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 chars : The characters address array to display
|
||||||
* @param size : the array size
|
* @param size : the array size
|
||||||
* @param x : the horizontal position of the value on screen
|
* @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
|
* @param inv : if 1 then color character will be inverted
|
||||||
* @code
|
* @code
|
||||||
* char chars[0x04,0x45,0x54]; //the chars addresses array to be send to function.
|
* 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
|
* @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 address : The address in character memory of the character to be displayed
|
||||||
* @param x : the horizontal position of the string on screen
|
* @param x : the horizontal position of the string on screen
|
||||||
* @param y : the vertical 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 blink : if 1 then character will blink
|
||||||
* @param inv : if 1 then color character will be inverted
|
* @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
|
* Print a character to Serial port
|
||||||
@ -229,7 +226,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
byte giveMax7456CharFromAsciiChar(char ascii);
|
byte giveMAX7456CharFromAsciiChar(char ascii);
|
||||||
static void printPixel(byte value);
|
static void printPixel(byte value);
|
||||||
|
|
||||||
byte _pinCS;
|
byte _pinCS;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* max7456Registers.h
|
* MAX7456Registers.h
|
||||||
*
|
*
|
||||||
* Created on: 13 oct. 2012
|
* Created on: 13 oct. 2012
|
||||||
* Author: Benoit
|
* Author: Benoit
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef charact
|
* @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];
|
typedef byte charact[54];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user