Compare commits
6 Commits
530fb9c111
...
master
Author | SHA1 | Date | |
---|---|---|---|
d9e5a34567 | |||
3fce356abf | |||
7ce4779101 | |||
3408e35786 | |||
1e99abecab | |||
1936746a40 |
@ -8,3 +8,4 @@ steps:
|
||||
- pip install platformio
|
||||
- pio ci --lib src/ examples/HelloWorld --board=pro16MHzatmega328
|
||||
- pio ci --lib src/ examples/Max7456Write --board=pro16MHzatmega328
|
||||
- pio ci --lib src/ examples/WriteMCM --board=pro16MHzatmega328
|
@ -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,49 +1,32 @@
|
||||
#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};
|
||||
byte tab[]={0xED,0xEE, 0xEF, 0xF3};
|
||||
|
||||
void setup()
|
||||
{
|
||||
SPI.begin();
|
||||
|
||||
osd.init(10);
|
||||
osd.init(6);
|
||||
osd.setDisplayOffsets(60,18);
|
||||
osd.setBlinkParams(_8fields, _BT_BT);
|
||||
osd.setBlinkParams(_8fields, _3BT_BT);
|
||||
|
||||
osd.activateOSD();
|
||||
osd.printMax7456Char(0x01,0,1);
|
||||
osd.printMAX7456Char(0x12,0,1);
|
||||
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.printMax7456Chars(tab,2,12,7);
|
||||
pinMode(redLed,OUTPUT);
|
||||
pinMode(greenLed,OUTPUT);
|
||||
osd.printMAX7456Chars(tab,sizeof(tab),12,1);
|
||||
|
||||
//base time = 160ms,time on = time off.
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if(counter%2 == 0)
|
||||
{
|
||||
digitalWrite(redLed,LOW);
|
||||
digitalWrite(greenLed,HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(redLed,HIGH);
|
||||
digitalWrite(greenLed,LOW);
|
||||
}
|
||||
|
||||
counter = millis()/1000;
|
||||
|
||||
osd.print(int(counter/60),10,6,2,0,false,true);
|
||||
|
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(115200);
|
||||
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 |
@ -1,34 +1,32 @@
|
||||
#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;
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(VM1_ADDRESS_WRITE);
|
||||
SPI.transfer(_regVm1.whole);
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::setDisplayOffsets
|
||||
// Implements MAX7456::setDisplayOffsets
|
||||
//----------------------------------------------------------------------------
|
||||
void Max7456::setDisplayOffsets(byte horizontal, byte vertical)
|
||||
void MAX7456::setDisplayOffsets(byte horizontal, byte vertical)
|
||||
{
|
||||
|
||||
_regHos.whole = 0;
|
||||
@ -37,41 +35,35 @@ void Max7456::setDisplayOffsets(byte horizontal, byte vertical)
|
||||
_regHos.bits.horizontalPositionOffset = horizontal;
|
||||
_regVos.bits.verticalPositionOffset = vertical;
|
||||
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(HOS_ADDRESS_WRITE);
|
||||
SPI.transfer(_regHos.whole);
|
||||
|
||||
SPI.transfer(VOS_ADDRESS_WRITE);
|
||||
SPI.transfer(_regVos.whole);
|
||||
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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, char address)
|
||||
{
|
||||
byte charAddress;
|
||||
if(y<0)
|
||||
charAddress = x;
|
||||
else
|
||||
charAddress = x + (y<<4);
|
||||
activateOSD(false);
|
||||
//datasheet p38
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(CMAH_ADDRESS_WRITE);
|
||||
SPI.transfer(charAddress);
|
||||
SPI.transfer(address);
|
||||
|
||||
for(byte i = 0 ; i < 54 ; i++)
|
||||
for (byte i = 0; i < 54; i++)
|
||||
{
|
||||
SPI.transfer(CMAL_ADDRESS_WRITE);
|
||||
SPI.transfer(i);
|
||||
@ -84,34 +76,30 @@ void Max7456::sendCharacter(const charact chara, byte x, byte y)
|
||||
SPI.transfer(_regCmm);
|
||||
//while STAT[5] is not good, we wait.
|
||||
_regStat.bits.characterMemoryStatus = 1;
|
||||
while( _regStat.bits.characterMemoryStatus ==1)
|
||||
while (_regStat.bits.characterMemoryStatus == 1)
|
||||
{
|
||||
SPI.transfer(STAT_ADDRESS_READ);
|
||||
_regStat.whole = SPI.transfer(0x00);
|
||||
}
|
||||
|
||||
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
|
||||
|
||||
if(y<=0)
|
||||
if (y <= 0)
|
||||
charAddress = x;
|
||||
else
|
||||
charAddress = x + y*16;
|
||||
charAddress = x + y * 16;
|
||||
|
||||
activateOSD(false);
|
||||
//datasheet p38
|
||||
digitalWrite(_pinCS,LOW);
|
||||
|
||||
digitalWrite(_pinCS, LOW);
|
||||
|
||||
SPI.transfer(CMAH_ADDRESS_WRITE);
|
||||
SPI.transfer(charAddress);
|
||||
@ -120,8 +108,7 @@ void Max7456::getCharacter(charact chara, byte x, byte y)
|
||||
SPI.transfer(CMM_ADDRESS_WRITE);
|
||||
SPI.transfer(_regCmm);
|
||||
|
||||
|
||||
for(byte i = 0 ; i < 54 ; i++)
|
||||
for (byte i = 0; i < 54; i++)
|
||||
{
|
||||
SPI.transfer(CMAL_ADDRESS_WRITE);
|
||||
SPI.transfer(i);
|
||||
@ -130,24 +117,22 @@ void Max7456::getCharacter(charact chara, byte x, byte y)
|
||||
chara[i] = SPI.transfer(0x00);
|
||||
}
|
||||
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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 ;
|
||||
car = Max7456::byteArray2CARACT(array);
|
||||
CARACT car;
|
||||
car = MAX7456::byteArray2CARACT(array);
|
||||
|
||||
Serial.println("------------");
|
||||
for(int i = 0 ; i < 18 ; i++)
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
for(int j = 0 ; j < 3 ; j++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
printPixel(car.line[i].pixels[j].pix0);
|
||||
printPixel(car.line[i].pixels[j].pix1);
|
||||
@ -163,26 +148,26 @@ void Max7456::printCharacterToSerial(const charact array, bool img)
|
||||
else
|
||||
{
|
||||
Serial.print("{");
|
||||
for(unsigned int i = 0 ; i < 53 ; i++)
|
||||
for (unsigned int i = 0; i < 53; i++)
|
||||
{
|
||||
Serial.print("0x");
|
||||
Serial.print(String(array[i],HEX));
|
||||
Serial.print(String(array[i], HEX));
|
||||
Serial.print(", ");
|
||||
}
|
||||
Serial.print("0x");
|
||||
Serial.print(String(array[53],HEX));
|
||||
Serial.print(String(array[53], HEX));
|
||||
Serial.println("};");
|
||||
}
|
||||
}
|
||||
|
||||
void Max7456::printPixel(byte value)
|
||||
void MAX7456::printPixel(byte value)
|
||||
{
|
||||
switch(value )
|
||||
switch (value)
|
||||
{
|
||||
case COLOR_BLACK :
|
||||
case COLOR_BLACK:
|
||||
Serial.print("#");
|
||||
return;
|
||||
case COLOR_WHITE :
|
||||
case COLOR_WHITE:
|
||||
Serial.print("*");
|
||||
return;
|
||||
default:
|
||||
@ -191,55 +176,54 @@ 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;
|
||||
char currentChar;
|
||||
byte size;
|
||||
byte *chars = NULL;
|
||||
|
||||
if(!string) return;
|
||||
if (!string)
|
||||
return;
|
||||
|
||||
size = 0;
|
||||
currentChar = string[0];
|
||||
|
||||
while(currentChar != '\0')
|
||||
while (currentChar != '\0')
|
||||
{
|
||||
currentChar = string[++size];
|
||||
}
|
||||
|
||||
chars = (byte*) malloc(size * sizeof(byte));
|
||||
chars = (byte *)malloc(size * sizeof(byte));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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 posAddressLO;
|
||||
byte posAddressHI;
|
||||
unsigned int posAddress;
|
||||
byte currentChar;
|
||||
byte posAddressLO;
|
||||
byte posAddressHI;
|
||||
unsigned int posAddress;
|
||||
|
||||
posAddress = 30*y+x;
|
||||
posAddress = 30 * y + x;
|
||||
|
||||
posAddressHI = posAddress >> 8;
|
||||
posAddressLO = posAddress;
|
||||
@ -249,85 +233,72 @@ void Max7456::printMax7456Chars(byte chars[],byte size,byte x, byte y, byte blin
|
||||
_regDmm.bits.INV = inv;
|
||||
_regDmm.bits.BLK = blink;
|
||||
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(DMM_ADDRESS_WRITE);
|
||||
|
||||
|
||||
|
||||
SPI.transfer(_regDmm.whole);
|
||||
|
||||
|
||||
SPI.transfer(DMAH_ADDRESS_WRITE); // set start address high
|
||||
SPI.transfer(posAddressHI);
|
||||
|
||||
SPI.transfer(DMAL_ADDRESS_WRITE); // set start address low
|
||||
SPI.transfer(posAddressLO);
|
||||
|
||||
|
||||
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(currentCharMax7456);
|
||||
|
||||
SPI.transfer(currentChar);
|
||||
}
|
||||
|
||||
//end character (we're done).
|
||||
SPI.transfer(DMDI_ADDRESS_WRITE);
|
||||
SPI.transfer(0xff);
|
||||
|
||||
/*
|
||||
_regVm0.bits.
|
||||
SPI.transfer(VM0_ADDRESS_WRITE);
|
||||
SPI.transfer(0x4c);*/
|
||||
|
||||
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
|
||||
strValue = (char*) malloc((before+after+2)* sizeof(char));
|
||||
strValue = (char *)malloc((before + after + 2) * sizeof(char));
|
||||
|
||||
|
||||
if(after==0)
|
||||
dtostrf(value,before+after,after,strValue);
|
||||
if (after == 0)
|
||||
dtostrf(value, before + after, after, strValue);
|
||||
else
|
||||
dtostrf(value,before+after+1,after,strValue);
|
||||
dtostrf(value, before + after + 1, after, strValue);
|
||||
|
||||
for(int i = 0 ; i < before+after+1;i++)
|
||||
{
|
||||
if(strValue[i] == ' ' || strValue[i] == '-')
|
||||
strValue[i]='0';
|
||||
}
|
||||
if(value < 0)
|
||||
strValue[0]='-';
|
||||
if(after==0) //If the result is bigger, we truncate it so the OSD won't be falsed.
|
||||
strValue[before]='\0';
|
||||
for (int i = 0; i < before + after + 1; i++)
|
||||
{
|
||||
if (strValue[i] == ' ' || strValue[i] == '-')
|
||||
strValue[i] = '0';
|
||||
}
|
||||
if (value < 0)
|
||||
strValue[0] = '-';
|
||||
if (after == 0) //If the result is bigger, we truncate it so the OSD won't be falsed.
|
||||
strValue[before] = '\0';
|
||||
else
|
||||
strValue[before+after+1]='\0';
|
||||
strValue[before + after + 1] = '\0';
|
||||
|
||||
print(strValue,x,y,blink,inv);
|
||||
print(strValue, x, y, blink, inv);
|
||||
|
||||
free(strValue);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::giveMax7456CharFromAsciiChar
|
||||
// Implements MAX7456::giveMAX7456CharFromAsciiChar
|
||||
//-----------------------------------------------------------------------------
|
||||
byte Max7456::giveMax7456CharFromAsciiChar(char ascii)
|
||||
byte MAX7456::giveMAX7456CharFromAsciiChar(char ascii)
|
||||
{
|
||||
#ifdef MAX7456_TABLE_ASCII
|
||||
if(ascii >= ' ' && ascii <= 'z')
|
||||
return ascii-' ';
|
||||
#error Do not be here
|
||||
if (ascii >= ' ' && ascii <= 'z')
|
||||
return ascii - ' ';
|
||||
else
|
||||
return ascii;
|
||||
#else
|
||||
@ -335,13 +306,12 @@ byte Max7456::giveMax7456CharFromAsciiChar(char ascii)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::clearScreen
|
||||
// Implements MAX7456::clearScreen
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::clearScreen()
|
||||
void MAX7456::clearScreen()
|
||||
{
|
||||
_regDmm.bits.clearDisplayMemory = 1 ;
|
||||
_regDmm.bits.clearDisplayMemory = 1;
|
||||
|
||||
digitalWrite(_pinCS, LOW);
|
||||
|
||||
@ -349,45 +319,43 @@ void Max7456::clearScreen()
|
||||
SPI.transfer(_regDmm.whole);
|
||||
|
||||
//wait for operation to be complete.
|
||||
while(_regDmm.bits.clearDisplayMemory == 1 )
|
||||
while (_regDmm.bits.clearDisplayMemory == 1)
|
||||
{
|
||||
SPI.transfer(DMM_ADDRESS_READ);
|
||||
_regDmm.whole = SPI.transfer(0x00);
|
||||
}
|
||||
digitalWrite(_pinCS, HIGH); //disable device
|
||||
digitalWrite(_pinCS, HIGH); //disable device
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::init
|
||||
// Implements MAX7456::init
|
||||
//-----------------------------------------------------------------------------
|
||||
void Max7456::init(byte iPinCS)
|
||||
void MAX7456::init(byte iPinCS)
|
||||
{
|
||||
_pinCS = iPinCS;
|
||||
_isActivatedOsd = false;
|
||||
|
||||
_regVm1.whole = 0b01000111;
|
||||
pinMode(iPinCS, OUTPUT);
|
||||
digitalWrite(iPinCS, HIGH); //disable device
|
||||
delay(100); //power up time
|
||||
digitalWrite(iPinCS, HIGH); //disable device
|
||||
delay(100); //power up time
|
||||
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(VM0_ADDRESS_WRITE);
|
||||
|
||||
_regVm0.whole = 0x00;
|
||||
_regVm0.bits.videoSelect=1; //PAL
|
||||
_regVm0.bits.videoSelect = 1; //PAL
|
||||
_regVm0.bits.softwareResetBit = 1;
|
||||
SPI.transfer(_regVm0.whole);
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
delay(500);
|
||||
|
||||
|
||||
digitalWrite(_pinCS,LOW);
|
||||
for(int x = 0 ; x < 16 ; x++)
|
||||
digitalWrite(_pinCS, LOW);
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
_regRb[x].whole = 0x00;
|
||||
_regRb[x].bits.characterWhiteLevel = 2;
|
||||
SPI.transfer(x+RB0_ADDRESS_WRITE);
|
||||
SPI.transfer(x + RB0_ADDRESS_WRITE);
|
||||
SPI.transfer(_regRb[x].whole);
|
||||
}
|
||||
|
||||
@ -399,99 +367,85 @@ void Max7456::init(byte iPinCS)
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
_regVm0.bits.videoSelect = 1;
|
||||
if(act)
|
||||
if (act)
|
||||
_regVm0.bits.enableOSD = 1;
|
||||
else
|
||||
_regVm0.bits.enableOSD = 0;
|
||||
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(VM0_ADDRESS_WRITE);
|
||||
SPI.transfer(_regVm0.whole);
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
_isActivatedOsd = 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
|
||||
else
|
||||
_regVm0.bits.synchSelect = 0; //0
|
||||
|
||||
digitalWrite(_pinCS,LOW);
|
||||
digitalWrite(_pinCS, LOW);
|
||||
SPI.transfer(VM0_ADDRESS_WRITE);
|
||||
SPI.transfer(_regVm0.whole);
|
||||
digitalWrite(_pinCS,HIGH);
|
||||
digitalWrite(_pinCS, HIGH);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implements Max7456::CARACT2ByteArray
|
||||
// Implements MAX7456::CARACT2ByteArray
|
||||
//-----------------------------------------------------------------------------
|
||||
byte* Max7456::CARACT2ByteArray(const CARACT car)
|
||||
byte *MAX7456::CARACT2ByteArray(const CARACT car)
|
||||
{
|
||||
byte *array = NULL;
|
||||
array = new charact;
|
||||
for(int i = 0 ; i < 54 ; i++)
|
||||
array[i]= car.whole[i];
|
||||
for (int i = 0; i < 54; i++)
|
||||
array[i] = car.whole[i];
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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++)
|
||||
for (int i = 0; i < 54; i++)
|
||||
car.whole[i] = array[i];
|
||||
|
||||
return car;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
index = i*54;
|
||||
for(unsigned long j = 0 ; j < 54 ; j++)
|
||||
index = i * 54;
|
||||
for (unsigned long j = 0; j < 54; j++)
|
||||
{
|
||||
read = pgm_read_byte_near(table +index+j );
|
||||
read = pgm_read_byte_near(table + index + j);
|
||||
car[j] = read;
|
||||
if (car[j] == 0x55)
|
||||
car[j] = 0xff;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* max7456.h
|
||||
* MAX7456.h
|
||||
*
|
||||
* Created on: 10 oct. 2012
|
||||
* Author: Benoit
|
||||
@ -9,55 +9,44 @@
|
||||
#ifndef 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 -> ' '
|
||||
//....
|
||||
// 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
|
||||
* @mainpage MAX7456 Arduino library
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example Max7456WriteTable.cpp
|
||||
* @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:
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@ -69,7 +58,6 @@ public:
|
||||
*/
|
||||
void setBlinkParams(byte blinkBase, byte blinkDC);
|
||||
|
||||
|
||||
/**
|
||||
* Set Horizontal and Vertical display offset
|
||||
* @param horizontal : the horizontal offset in pixels (between 0 and 63).
|
||||
@ -77,13 +65,11 @@ public:
|
||||
*/
|
||||
void setDisplayOffsets(byte horizontal, byte vertical);
|
||||
|
||||
|
||||
/**
|
||||
* Erase Display Memory.
|
||||
*/
|
||||
void clearScreen();
|
||||
|
||||
|
||||
/**
|
||||
* Activate osd on screen
|
||||
* @param act :
|
||||
@ -92,7 +78,6 @@ public:
|
||||
*/
|
||||
void activateOSD(bool act = true);
|
||||
|
||||
|
||||
/**
|
||||
* Activate input video as a background
|
||||
* @param activExtVid :
|
||||
@ -101,20 +86,17 @@ public:
|
||||
*/
|
||||
void activateExternalVideo(bool activExtVid = true);
|
||||
|
||||
|
||||
/**
|
||||
* Put a character in the memory character of max7456
|
||||
* Put a character in the memory character of MAX7456
|
||||
* @param array : the byte array representing the character (54 bytes long)
|
||||
* @param x : the horizontal position of character in memory
|
||||
* @param y : the vertical position of character in memory.
|
||||
* @param adress : the address of character in memory
|
||||
* @code
|
||||
* charact c={0x44,....} //Whatever charact here
|
||||
* max.sendCharacter(c,4,5); //put c at 4th line 5th column ie. address 54.
|
||||
* max.sendCharacter(c,0x54); //put c at 4th line 5th column ie. address 54.
|
||||
* max.sendCharacter(c,0x43); //put c in mem at address 43.
|
||||
* @endcode
|
||||
*/
|
||||
void sendCharacter(const charact array, byte x, byte y);
|
||||
|
||||
void sendCharacter(const charact array, char address);
|
||||
|
||||
/**
|
||||
* Get a character from the character memory of max7456
|
||||
@ -124,7 +106,6 @@ public:
|
||||
*/
|
||||
void getCharacter(charact array, byte x, byte y);
|
||||
|
||||
|
||||
/**
|
||||
* Put a string in the display memory of max7456
|
||||
* @param string : The string to be displayed
|
||||
@ -137,9 +118,7 @@ public:
|
||||
* characters the ascii characters between ' ' and 'z'
|
||||
* (' ' being at address 0x00, z being at address 'z'-' ').
|
||||
*/
|
||||
void print(const char string[], byte x, byte y, byte blink = 0,byte inv = 0);
|
||||
|
||||
|
||||
void print(const char string[], byte x, byte y, byte blink = 0, byte inv = 0);
|
||||
|
||||
/**
|
||||
* Put a float in the display memory of max7456
|
||||
@ -159,13 +138,12 @@ public:
|
||||
* //Will print "003.1400" on screen
|
||||
* @endcode
|
||||
*/
|
||||
void print(double value, byte x, byte y, byte before, byte after, byte blink=0,byte inv=0);
|
||||
|
||||
void print(double value, byte x, byte y, byte before, byte after, byte blink = 0, byte inv = 0);
|
||||
|
||||
/**
|
||||
* 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 +152,20 @@ 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
|
||||
@ -199,14 +176,12 @@ public:
|
||||
*/
|
||||
static void printCharacterToSerial(const charact array, bool img = true);
|
||||
|
||||
|
||||
/**
|
||||
* Converts a CARACT character to a byte array representation.
|
||||
* @param car : the CARACT character
|
||||
* @return : the byte array representing the character (54 bytes long)
|
||||
*/
|
||||
static byte* CARACT2ByteArray(const CARACT car);
|
||||
|
||||
static byte *CARACT2ByteArray(const CARACT car);
|
||||
|
||||
/**
|
||||
* Converts a byte array to a CARACT character.
|
||||
@ -215,7 +190,6 @@ public:
|
||||
*/
|
||||
static CARACT byteArray2CARACT(const charact array);
|
||||
|
||||
|
||||
/**
|
||||
* Get the ith character from program memory
|
||||
* @param table the address of the array in prog memory
|
||||
@ -225,36 +199,33 @@ public:
|
||||
* @note When accessing this array, 0x55 are interpreted as 0xFF (you can't have 0xFF in program memory.
|
||||
* @note See file example for more informations.
|
||||
*/
|
||||
static void getCARACFromProgMem(const char *table, byte i,charact c);
|
||||
static void getCARACFromProgMem(const char *table, byte i, charact c);
|
||||
|
||||
private:
|
||||
|
||||
byte giveMax7456CharFromAsciiChar(char ascii);
|
||||
byte giveMAX7456CharFromAsciiChar(char ascii);
|
||||
static void printPixel(byte value);
|
||||
|
||||
byte _pinCS;
|
||||
bool _isActivatedOsd;
|
||||
//registers (only here for convenience : not forced to be used).
|
||||
REG_VM0 _regVm0;
|
||||
REG_VM1 _regVm1;
|
||||
REG_HOS _regHos;
|
||||
REG_VOS _regVos;
|
||||
REG_DMM _regDmm;
|
||||
REG_DMAH _regDmah; // not used yet
|
||||
REG_DMAL _regDmal; // not used yet
|
||||
REG_DMDI _regDmdi; // not used yet
|
||||
REG_CMM _regCmm;
|
||||
REG_CMAH _regCmah; // not used yet
|
||||
REG_CMAL _regCmal; // not used yet
|
||||
REG_CMDI _regCmdi; // not used yet
|
||||
REG_OSDM _regOsdm; // not used yet
|
||||
REG_RBN _regRb[16]; // not used yet
|
||||
REG_VM0 _regVm0;
|
||||
REG_VM1 _regVm1;
|
||||
REG_HOS _regHos;
|
||||
REG_VOS _regVos;
|
||||
REG_DMM _regDmm;
|
||||
REG_DMAH _regDmah; // not used yet
|
||||
REG_DMAL _regDmal; // not used yet
|
||||
REG_DMDI _regDmdi; // not used yet
|
||||
REG_CMM _regCmm;
|
||||
REG_CMAH _regCmah; // not used yet
|
||||
REG_CMAL _regCmal; // not used yet
|
||||
REG_CMDI _regCmdi; // not used yet
|
||||
REG_OSDM _regOsdm; // not used yet
|
||||
REG_RBN _regRb[16]; // not used yet
|
||||
REG_OSDBL _regOsdbl; // not used yet
|
||||
REG_STAT _regStat; // not used yet
|
||||
DMDO _regDmdo; // not used yet
|
||||
REG_CMDO _regCmdo; // not used yet
|
||||
REG_STAT _regStat; // not used yet
|
||||
DMDO _regDmdo; // not used yet
|
||||
REG_CMDO _regCmdo; // not used yet
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAX7456_H_ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* max7456Registers.h
|
||||
* MAX7456Registers.h
|
||||
*
|
||||
* Created on: 13 oct. 2012
|
||||
* Author: Benoit
|
||||
@ -8,13 +8,11 @@
|
||||
#ifndef MAX7456REGISTERS_H_
|
||||
#define MAX7456REGISTERS_H_
|
||||
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
/**
|
||||
* @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];
|
||||
|
||||
@ -28,7 +26,7 @@ typedef byte charact[54];
|
||||
union REG_VM0
|
||||
{
|
||||
/**@brief The whole value*/
|
||||
unsigned char whole ;
|
||||
unsigned char whole;
|
||||
/**
|
||||
* @var bits
|
||||
* @brief access to individual bits*/
|
||||
@ -38,7 +36,7 @@ union REG_VM0
|
||||
* @li 0 = Enable
|
||||
* @li 1 = Disable(VOUT is high impedance)
|
||||
*/
|
||||
unsigned char videoBuffer :1;
|
||||
unsigned char videoBuffer : 1;
|
||||
|
||||
/**@brief Software Reset Bit
|
||||
* @li When bit set all register are set to default.
|
||||
@ -68,7 +66,7 @@ union REG_VM0
|
||||
* @li 0 = NTSC
|
||||
* @li 1 = PAL
|
||||
*/
|
||||
unsigned char videoSelect :1;
|
||||
unsigned char videoSelect : 1;
|
||||
|
||||
/**@brief don't care*/
|
||||
unsigned char unused : 1;
|
||||
@ -76,7 +74,6 @@ union REG_VM0
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define VM1_ADDRESS_WRITE 0x01
|
||||
#define VM1_ADDRESS_READ 0x81
|
||||
|
||||
@ -101,7 +98,6 @@ union REG_VM1
|
||||
*/
|
||||
unsigned char blinkingDutyCycle : 2;
|
||||
|
||||
|
||||
/**@brief Blinking Time (BT)
|
||||
* @li b00 (0) = 2 fields (NTSC = 33ms ; PAL = 40ms)
|
||||
* @li b01 (1) = 4 fields (NTSC = 67ms ; PAL = 80ms)
|
||||
@ -110,7 +106,6 @@ union REG_VM1
|
||||
*/
|
||||
unsigned char blinkingTime : 2;
|
||||
|
||||
|
||||
/**@brief Background Mode Brightness
|
||||
* @li b000 (0) = 0%
|
||||
* @li b001 (1) = 7%
|
||||
@ -163,7 +158,6 @@ union REG_HOS
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define VOS_ADDRESS_WRITE 0x03
|
||||
#define VOS_ADDRESS_READ 0x83
|
||||
|
||||
@ -264,12 +258,9 @@ union REG_DMM
|
||||
/**@brief Don't care*/
|
||||
unsigned char unsused : 1;
|
||||
|
||||
|
||||
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define DMAH_ADDRESS_WRITE 0x05
|
||||
#define DMAH_ADDRESS_READ 0x85
|
||||
/**@union REG_DMAH
|
||||
@ -293,12 +284,10 @@ union REG_DMAH
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define DMAL_ADDRESS_WRITE 0x06
|
||||
#define DMAL_ADDRESS_READ 0x86
|
||||
typedef unsigned char REG_DMAL;
|
||||
|
||||
|
||||
#define DMDI_ADDRESS_WRITE 0x07
|
||||
#define DMDI_ADDRESS_READ 0x87
|
||||
typedef unsigned char REG_DMDI;
|
||||
@ -353,7 +342,6 @@ union REG_CMDI
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define OSDM_ADDRESS_WRITE 0x0C
|
||||
#define OSDM_ADDRESS_READ 0x8C
|
||||
|
||||
@ -380,7 +368,6 @@ union REG_OSDM
|
||||
*/
|
||||
unsigned char osdInsertionMuxSwitchingTime : 3;
|
||||
|
||||
|
||||
/**@brief OSD Rise And Fall Time
|
||||
* @li b000 (0) : 20ns (maximum sharpness/maximum crosscolor artifacts )
|
||||
* @li b001 (1) : 30ns
|
||||
@ -391,14 +378,12 @@ union REG_OSDM
|
||||
*/
|
||||
unsigned char osdRiseAndFallTime : 3;
|
||||
|
||||
|
||||
/**@brief don't care*/
|
||||
unsigned char unused : 2;
|
||||
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define RB0_ADDRESS_WRITE 0x10
|
||||
#define RB0_ADDRESS_READ 0x90
|
||||
|
||||
@ -562,7 +547,6 @@ union REG_STAT
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
#define DMDO_ADDRESS_READ 0xB0
|
||||
|
||||
/**@typedef DMDO
|
||||
@ -595,33 +579,26 @@ union REG_CMDO
|
||||
} bits;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**\def COLOR_BLACK
|
||||
* \brief Black value for a pixel (2bits)
|
||||
*/
|
||||
#define COLOR_BLACK 0
|
||||
|
||||
#define COLOR_BLACK 0
|
||||
|
||||
/**\def COLOR_WHITE
|
||||
* \brief White value for a pixel (2bits)
|
||||
*/
|
||||
#define COLOR_WHITE 2
|
||||
|
||||
#define COLOR_WHITE 2
|
||||
|
||||
/**\def COLOR_TRANSPARENT
|
||||
* \brief Transparent value for a pixel (2bits)
|
||||
*/
|
||||
#define COLOR_TRANSPARENT 1
|
||||
|
||||
|
||||
/**\def COLOR_GREY
|
||||
* \brief Grey value for a pixel (2bits)
|
||||
*/
|
||||
#define COLOR_GREY COLOR_TRANSPARENT
|
||||
|
||||
|
||||
/**@struct PIXEL
|
||||
* @brief represent a 4-pixels value
|
||||
*/
|
||||
@ -634,10 +611,8 @@ struct PIXEL
|
||||
/**@brief 2nd pixel*/
|
||||
byte pix1 : 2;
|
||||
|
||||
|
||||
/**@brief 1st pixel*/
|
||||
byte pix0 : 2;
|
||||
|
||||
};
|
||||
|
||||
/**@union LINE
|
||||
@ -651,7 +626,6 @@ union LINE
|
||||
struct PIXEL pixels[3];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @union CARACT
|
||||
* @brief Represents a character with lines and pixels.
|
||||
@ -665,20 +639,20 @@ union CARACT
|
||||
union LINE line[18];
|
||||
};
|
||||
|
||||
|
||||
enum{
|
||||
_BT_BT=0,
|
||||
_BT_2BT,
|
||||
_BT_3BT,
|
||||
_3BT_BT
|
||||
enum
|
||||
{
|
||||
_BT_BT = 0,
|
||||
_BT_2BT,
|
||||
_BT_3BT,
|
||||
_3BT_BT
|
||||
};
|
||||
|
||||
enum{
|
||||
_2fields=0,
|
||||
_4fields,
|
||||
_6fields,
|
||||
_8fields
|
||||
enum
|
||||
{
|
||||
_2fields = 0,
|
||||
_4fields,
|
||||
_6fields,
|
||||
_8fields
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAX7456REGISTERS_H_ */
|
Reference in New Issue
Block a user