Compare commits

..

No commits in common. "d9e5a345676b2f2de299e5e843a3806e1487b033" and "7ce4779101b12ba01d5569a3987411de86bb6fba" have entirely different histories.

5 changed files with 230 additions and 140 deletions

@ -1416,8 +1416,8 @@ void setup() {
Serial.print(number);
Serial.println(F(" of 255"));
MAX7456::getCARACFromProgMem(tableOfAllCharacters, i, currentChar); //Because the table is too big for ram memory
MAX7456::printCharacterToSerial(tableOfAllCharacters[i], true);
osd->sendCharacter(currentChar, i); //We send currentChar at address i.
osd->sendCharacter(currentChar, i & 0xF0, i & 0xF0); //We send currentChar at address i.
}
Serial.println(F("---------- DONE! ----------"));
Serial.println(F("please unplug your arduino."));

@ -74,7 +74,7 @@ void setup()
{
byte spi_junk;
int x;
Serial.begin(115200);
Serial.begin(38400);
Serial.flush();
digitalWrite(USBSELECT,HIGH); //disable USB chip

@ -2,6 +2,7 @@
#include <Arduino.h>
#include <SPI.h>
//-----------------------------------------------------------------------------
// Implements MAX7456::MAX7456
//-----------------------------------------------------------------------------
@ -23,6 +24,7 @@ void MAX7456::setBlinkParams(byte blinkBase, byte blinkDC)
digitalWrite(_pinCS,HIGH);
}
//-----------------------------------------------------------------------------
// Implements MAX7456::setDisplayOffsets
//----------------------------------------------------------------------------
@ -52,16 +54,22 @@ MAX7456::MAX7456()
{
}
//-----------------------------------------------------------------------------
// Implements MAX7456::sendCharacter
//-----------------------------------------------------------------------------
void MAX7456::sendCharacter(const charact chara, char address)
void MAX7456::sendCharacter(const charact chara, byte x, byte y)
{
byte charAddress;
if(y<0)
charAddress = x;
else
charAddress = x + (y<<4);
activateOSD(false);
//datasheet p38
digitalWrite(_pinCS,LOW);
SPI.transfer(CMAH_ADDRESS_WRITE);
SPI.transfer(address);
SPI.transfer(charAddress);
for(byte i = 0 ; i < 54 ; i++)
{
@ -82,9 +90,11 @@ void MAX7456::sendCharacter(const charact chara, char address)
_regStat.whole = SPI.transfer(0x00);
}
digitalWrite(_pinCS,HIGH);
}
//-----------------------------------------------------------------------------
// Implements MAX7456::getCharacter
//-----------------------------------------------------------------------------
@ -92,6 +102,7 @@ void MAX7456::getCharacter(charact chara, byte x, byte y)
{
byte charAddress;
if(y<=0)
charAddress = x;
else
@ -101,6 +112,7 @@ void MAX7456::getCharacter(charact chara, byte x, byte y)
//datasheet p38
digitalWrite(_pinCS,LOW);
SPI.transfer(CMAH_ADDRESS_WRITE);
SPI.transfer(charAddress);
@ -108,6 +120,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++)
{
SPI.transfer(CMAL_ADDRESS_WRITE);
@ -118,12 +131,14 @@ void MAX7456::getCharacter(charact chara, byte x, byte y)
}
digitalWrite(_pinCS,HIGH);
}
//-----------------------------------------------------------------------------
// Implements Max7456::printCharacterToSerial
//-----------------------------------------------------------------------------
void MAX7456::printCharacterToSerial(const charact array, bool img)
{
if(img)
{
CARACT car ;
@ -176,6 +191,7 @@ void MAX7456::printPixel(byte value)
}
}
//-----------------------------------------------------------------------------
// Implements MAX7456::print
//-----------------------------------------------------------------------------
@ -185,8 +201,7 @@ void MAX7456::print(const char string[], byte x, byte y, byte blink, byte inv)
byte size;
byte *chars = NULL;
if (!string)
return;
if(!string) return;
size = 0;
currentChar = string[0];
@ -207,6 +222,7 @@ void MAX7456::print(const char string[], byte x, byte y, byte blink, byte inv)
free(chars);
}
void MAX7456::printMAX7456Char(const byte address, byte x, byte y, byte blink, byte inv)
{
byte ad = address;
@ -236,28 +252,40 @@ void MAX7456::printMAX7456Chars(byte chars[], byte size, byte x, byte y, byte bl
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++)
{
currentChar = chars[i];
SPI.transfer(DMDI_ADDRESS_WRITE);
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);
}
//-----------------------------------------------------------------------------
// Implements MAX7456::print
//-----------------------------------------------------------------------------
@ -268,6 +296,7 @@ void MAX7456::print(double value, byte x, byte y, byte before, byte after, byte
strValue = (char*) malloc((before+after+2)* sizeof(char));
if(after==0)
dtostrf(value,before+after,after,strValue);
else
@ -290,6 +319,7 @@ void MAX7456::print(double value, byte x, byte y, byte before, byte after, byte
free(strValue);
}
//-----------------------------------------------------------------------------
// Implements MAX7456::giveMAX7456CharFromAsciiChar
//-----------------------------------------------------------------------------
@ -306,6 +336,7 @@ byte MAX7456::giveMAX7456CharFromAsciiChar(char ascii)
#endif
}
//-----------------------------------------------------------------------------
// Implements MAX7456::clearScreen
//-----------------------------------------------------------------------------
@ -327,6 +358,7 @@ void MAX7456::clearScreen()
digitalWrite(_pinCS, HIGH); //disable device
}
//-----------------------------------------------------------------------------
// Implements MAX7456::init
//-----------------------------------------------------------------------------
@ -350,6 +382,7 @@ void MAX7456::init(byte iPinCS)
digitalWrite(_pinCS,HIGH);
delay(500);
digitalWrite(_pinCS,LOW);
for(int x = 0 ; x < 16 ; x++)
{
@ -370,6 +403,7 @@ void MAX7456::init(byte iPinCS)
digitalWrite(_pinCS,HIGH);
}
//-----------------------------------------------------------------------------
// Implements MAX7456::activateOSD
//-----------------------------------------------------------------------------
@ -392,6 +426,7 @@ void MAX7456::activateOSD(bool act)
}
}
//-----------------------------------------------------------------------------
// Implements MAX7456::activateExternalVideo
//-----------------------------------------------------------------------------
@ -408,6 +443,7 @@ void MAX7456::activateExternalVideo(bool activExtVid)
digitalWrite(_pinCS,HIGH);
}
//-----------------------------------------------------------------------------
// Implements MAX7456::CARACT2ByteArray
//-----------------------------------------------------------------------------
@ -421,6 +457,7 @@ byte *MAX7456::CARACT2ByteArray(const CARACT car)
return array;
}
//-----------------------------------------------------------------------------
// Implements MAX7456::byteArray2CARACT
//-----------------------------------------------------------------------------
@ -433,6 +470,7 @@ CARACT MAX7456::byteArray2CARACT(const charact array)
return car;
}
//-----------------------------------------------------------------------------
// Implements MAX7456::getCARACFromProgMem
//-----------------------------------------------------------------------------

@ -9,6 +9,7 @@
#ifndef MAX7456_H
#define MAX7456_H
//def next only if you changed your table for an ascii one
//i.e address 0x00 -> ' '
//....
@ -18,10 +19,13 @@
#include "MAX7456Registers.h"
/**
* @mainpage MAX7456 Arduino library
*/
/**
* @class MAX7456
* @brief Represents a MAX7456 device communicating through SPI port
@ -29,11 +33,14 @@
class MAX7456
{
public:
/**
* Default constructor
*/
MAX7456();
/**
* Constructor
* Initialize communications and device
@ -41,6 +48,7 @@ public:
*/
MAX7456(byte pinCS);
/**
* Initialize communications and device
* @param pinCS : pin ~CS of the arduino where MAX7456 is plugged.
@ -58,6 +66,7 @@ public:
*/
void setBlinkParams(byte blinkBase, byte blinkDC);
/**
* Set Horizontal and Vertical display offset
* @param horizontal : the horizontal offset in pixels (between 0 and 63).
@ -65,11 +74,13 @@ public:
*/
void setDisplayOffsets(byte horizontal, byte vertical);
/**
* Erase Display Memory.
*/
void clearScreen();
/**
* Activate osd on screen
* @param act :
@ -78,6 +89,7 @@ public:
*/
void activateOSD(bool act = true);
/**
* Activate input video as a background
* @param activExtVid :
@ -86,17 +98,20 @@ 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 adress : the address of character in memory
* @param x : the horizontal position of character in memory
* @param y : the vertical position of character in memory.
* @code
* charact c={0x44,....} //Whatever charact here
* max.sendCharacter(c,0x54); //put c at 4th line 5th column ie. address 54.
* max.sendCharacter(c,4,5); //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, char address);
void sendCharacter(const charact array, byte x, byte y);
/**
* Get a character from the character memory of max7456
@ -106,6 +121,7 @@ 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
@ -120,6 +136,8 @@ public:
*/
void print(const char string[], byte x, byte y, byte blink = 0,byte inv = 0);
/**
* Put a float in the display memory of max7456
* @param value : The value to be displayed
@ -140,6 +158,7 @@ public:
*/
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.
* The characters are given by their address in the
@ -157,6 +176,7 @@ public:
*/
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
* @param address : The address in character memory of the character to be displayed
@ -176,6 +196,7 @@ public:
*/
static void printCharacterToSerial(const charact array, bool img = true);
/**
* Converts a CARACT character to a byte array representation.
* @param car : the CARACT character
@ -183,6 +204,7 @@ public:
*/
static byte* CARACT2ByteArray(const CARACT car);
/**
* Converts a byte array to a CARACT character.
* @param array : the byte array representing the character (54 bytes long)
@ -190,6 +212,7 @@ public:
*/
static CARACT byteArray2CARACT(const charact array);
/**
* Get the ith character from program memory
* @param table the address of the array in prog memory
@ -202,6 +225,7 @@ public:
static void getCARACFromProgMem(const char *table, byte i,charact c);
private:
byte giveMAX7456CharFromAsciiChar(char ascii);
static void printPixel(byte value);
@ -228,4 +252,6 @@ private:
REG_CMDO _regCmdo; // not used yet
};
#endif /* MAX7456_H_ */

@ -8,8 +8,10 @@
#ifndef MAX7456REGISTERS_H_
#define MAX7456REGISTERS_H_
#include <Arduino.h>
/**
* @typedef charact
* @brief Represents a character as stored in MAX7456 character memory.
@ -74,6 +76,7 @@ union REG_VM0
} bits;
};
#define VM1_ADDRESS_WRITE 0x01
#define VM1_ADDRESS_READ 0x81
@ -98,6 +101,7 @@ 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)
@ -106,6 +110,7 @@ union REG_VM1
*/
unsigned char blinkingTime : 2;
/**@brief Background Mode Brightness
* @li b000 (0) = 0%
* @li b001 (1) = 7%
@ -158,6 +163,7 @@ union REG_HOS
} bits;
};
#define VOS_ADDRESS_WRITE 0x03
#define VOS_ADDRESS_READ 0x83
@ -258,9 +264,12 @@ 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
@ -284,10 +293,12 @@ 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;
@ -342,6 +353,7 @@ union REG_CMDI
} bits;
};
#define OSDM_ADDRESS_WRITE 0x0C
#define OSDM_ADDRESS_READ 0x8C
@ -368,6 +380,7 @@ 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
@ -378,12 +391,14 @@ 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
@ -547,6 +562,7 @@ union REG_STAT
} bits;
};
#define DMDO_ADDRESS_READ 0xB0
/**@typedef DMDO
@ -579,26 +595,33 @@ union REG_CMDO
} bits;
};
/**\def COLOR_BLACK
* \brief Black value for a pixel (2bits)
*/
#define COLOR_BLACK 0
/**\def COLOR_WHITE
* \brief White value for a pixel (2bits)
*/
#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
*/
@ -611,8 +634,10 @@ struct PIXEL
/**@brief 2nd pixel*/
byte pix1 : 2;
/**@brief 1st pixel*/
byte pix0 : 2;
};
/**@union LINE
@ -626,6 +651,7 @@ union LINE
struct PIXEL pixels[3];
};
/**
* @union CARACT
* @brief Represents a character with lines and pixels.
@ -639,20 +665,20 @@ union CARACT
union LINE line[18];
};
enum
{
enum{
_BT_BT=0,
_BT_2BT,
_BT_3BT,
_3BT_BT
};
enum
{
enum{
_2fields=0,
_4fields,
_6fields,
_8fields
};
#endif /* MAX7456REGISTERS_H_ */