Chapter 8: C Pointers and Arrays
ter to the string array stored
osition. Okay, this is a bit complex so Let’s write
alking about.
e PC_Comm software so we can use this messenger
s the RAM that has up to now been wasted on
he old PC_Comm code after this).
senger, and copy from the PC_Comm directory the .c
e.
ecifically
PROGMEM = "\r\rYou are talking to the \0";
OGMEM = "'Messenger' demo.\r\r\0";
ND1[] PROGMEM = "\rYou sent: '\0";
ND2[] PROGMEM = "' - I don't understand.\r\0";
a ";
or error message: ";
PROGMEM = "You fouled up beyond
OGMEM = "Situation normal, all fouled
ADNESS[] PROGMEM = "Stop the madness!\r\0";
here did you learn to program?\r\0";
d the freaking manual!\r\0";
_YOUFOOBARED, ERROR_SNAFUED,
RROR_RTFM };
send the FOR message. And finally we send the poin
in the ERROR_TBL in the i p
some code to show what we’re t
The messenger software.
We are going to upgrade th
stuff in later code. This will save u
constant strings. (Note – don’t use t
Create a new directory, Mes
and .h files and the makefil
In Programmers Notepad create a new file Messages.h:
// Messages.h
// identify yourself sp
const char TALKING_TO[]
const char WHO_DEMO[] PR
// bad command
const char BAD_COMMA
const char BAD_COMMA
const char ENTER[] PROGMEM = "Enter
const char FOR[] PROGMEM = " f
const char ERROR_YOUFOOBARED[]
repair.\r\0";
c har ERROR_SNAFUED[] PRonst c
up.\r\0";
const char ERROR_STOPTHEM
c har ERROR_WHERE[] PROGMEM = "Wonst c
const char ERROR_RTFM[] PROGMEM = "Rea
const char *ERROR_TBL[] = { ERROR
ERROR_STOPTHEMADNESS, ERROR_WHERE, E
and save it in the Messenger directory.
Add to the PC_Comm.h file:
#include <avr/pgmspace.h>