hi guys may i know how can i store the inputs i keyed in and still can display it after i restart the device. for example: i store ABC then i switch off, when i switch on again and press display it will show ABC without having me to key in all over again. now it would reset automatically everytime i restart the device. thank you so much!
Rich (BB code):
#include "p18f45K20.h"
#include "delays.h"
int Cases = 0;
int Letter = 0;
int Letter2 = 0;
int Store = 0;
int Seq = 0;
int Restore = 0;
int StorageArray[];
/* Delays 4Mhz
Delay1TCY (); // gives a delay of 1 us (implemented as a single NOP instruction).
Delay10TCYx (60); // gives a delay of 10 x 60 x 1us = 600us
Delay100TCYx (60); // gives a delay of 100 x 120 x 1us = 60ms
Delay1KTCYx (60); // gives a delay of 1000 x 240 x 1us = 600ms
Delay10KTCYx (60); // gives a delay of 10000 x 25 x 1us = 6sec
*/
//Start of Program ~ flow chart(1)
rom char Sequences[26][1] =
{ 0x01,//A
0x02,//B
0x04,//C
0x08,//D
0x10,//E
0x20,//F
0x40,//G
0x80,//H
0x03,//I
0x06,//J
0x0C,//K
0x18,//L
0x30,//M
0x60,//N
0xC0,//O
0x07,//P
0x0E,//Q
0x1C,//R
0x38,//S
0x70,//T
0xE0,//U
0x0F,//V
0x1E,//W
0x3C,//X
0x78,//Y
0xF0,//Z
};
//Declaring All the Words
rom char Characters[52][7] =
{ 0x00, 0x00, 0x7F, 0x88, 0x88, 0x88, 0x7F, //A
0x00, 0x00, 0xFF, 0x91, 0x91, 0x91, 0x6E, //B
0x00, 0x00, 0x7E, 0x81, 0x81, 0x81, 0x66, //C
0x00, 0x00, 0xFF, 0x81, 0x81, 0x42, 0x3C, //D
0x00, 0x00, 0xFF, 0x91, 0x91, 0x91, 0x91, //E
0x00, 0x00, 0xFF, 0x90, 0x90, 0x90, 0x90, //F
0x00, 0x00, 0x7E, 0x81, 0x89, 0x89, 0x4E, //G
0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0xFF, //H
0x00, 0x00, 0x81, 0x81, 0xFF, 0x81, 0x81, //I
0x00, 0x00, 0x87, 0x81, 0xFF, 0x80, 0x80, //J
0x00, 0x00, 0xFF, 0x10, 0x28, 0x44, 0x83, //K
0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, //L
0x00, 0x00, 0x7F, 0x80, 0x7C, 0x80, 0x7F, //M
0x00, 0xFF, 0x40, 0x30, 0x0C, 0x02, 0xFF, //N
0x00, 0x00, 0x7E, 0x81, 0x81, 0x81, 0x7F, //O
0x00, 0x00, 0xFF, 0x88, 0x88, 0x88, 0x60, //P
0x00, 0x00, 0x7C, 0x82, 0x82, 0x82, 0x7D, //Q
0x00, 0x00, 0xFF, 0x98, 0x94, 0x92, 0x61, //R
0x00, 0x00, 0x66, 0x91, 0x91, 0x91, 0x4E, //S
0x00, 0x00, 0x80, 0x80, 0xFF, 0x80, 0x80, //T
0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0xFF, //U
0x00, 0x00, 0xF8, 0x06, 0x01, 0x06, 0xF8, //V
0x00, 0x00, 0xFE, 0x01, 0x1E, 0x01, 0xFE, //W
0x00, 0x00, 0xC7, 0x28, 0x10, 0x28, 0xC7, //X
0x00, 0x00, 0xC0, 0x30, 0x0F, 0x30, 0xC0, //Y
0x00, 0x00, 0x83, 0x85, 0x89, 0x91, 0xE1, //Z
0x00, 0x00, 0x17, 0x15, 0x15, 0x1F, 0x00, //a
0x00, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x09, //b
0x00, 0x00, 0x0E, 0x09, 0x09, 0x09, 0x0A, //c
0x00, 0x00, 0x0F, 0x09, 0x09, 0x7F, 0x00, //d
0x00, 0x00, 0x0E, 0x15, 0x15, 0x15, 0x0D, //e
0x00, 0x00, 0x08, 0x08, 0x7F, 0x48, 0x48, //f
0x00, 0x00, 0x00, 0x3B, 0x29, 0x29, 0x3F, //g
0x00, 0x00, 0x00, 0x3F, 0x04, 0x04, 0x07, //h
0x00, 0x00, 0x00, 0x00, 0x2F, 0x00, 0x00, //i
0x00, 0x00, 0x03, 0x01, 0x2F, 0x00, 0x00, //j
0x00, 0x00, 0x3F, 0x08, 0x14, 0x23, 0x3F, //k
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, //l
0x00, 0x00, 0x1F, 0x20, 0x18, 0x20, 0x1F, //m
0x00, 0x00, 0x3F, 0x20, 0x20, 0x3F, 0x00, //n
0x00, 0x00, 0x1E, 0x21, 0x21, 0x1E, 0x00, //o
0x00, 0x00, 0x3F, 0x28, 0x28, 0x38, 0x00, //p
0x00, 0x00, 0x38, 0x28, 0x28, 0x3F, 0x00, //q
0x00, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x20, //r
0x00 ,0x00, 0x00, 0x1D, 0x15, 0x15, 0x17, //s
0x00, 0x00, 0x00, 0x08, 0x3F, 0x08, 0x00, //t
0x00, 0x00, 0x1E, 0x01, 0x01, 0x1E, 0x00, //u
0x00, 0x00, 0x00, 0x1E, 0x01, 0x1E, 0x00, //v
0x00, 0x00, 0x1E, 0x01, 0x06, 0x01, 0x1E, //w
0x00, 0x00, 0x21, 0x12, 0x04, 0x12, 0x21, //x
0x00, 0x00, 0x00, 0x38, 0x09, 0x09, 0x3F, //y
0x00, 0x00, 0x00, 0x23, 0x25, 0x29, 0x31 //z
};
void main()
{
INTCON2bits.RBPU = 0;
TRISB = 0b00000000;
ANSELH = 0b00000000;
TRISD = 0x00;
TRISB = 0xFF;
PORTD = 0x00;
if (PORTBbits.RB0 == 0)
PORTD = 0xFF;
else
PORTD = 0x00;
//Making All Of PORTD Outputs
Wait:
if (PORTBbits.RB3 == 0)
{
WaitA:
if (PORTBbits.RB3 != 0)
{
Start();
}
else
{
goto WaitA;
}
}
else
goto Wait;
}
int Start()
{
Selections:
switch(Cases)
{
case 0: Letter = 0; goto StartOfProgram;
case 1: Letter = 1; goto StartOfProgram;
case 2: Letter = 2; goto StartOfProgram;
case 3: Letter = 3; goto StartOfProgram;
case 4: Letter = 4; goto StartOfProgram;
case 5: Letter = 5; goto StartOfProgram;
case 6: Letter = 6; goto StartOfProgram;
case 7: Letter = 7; goto StartOfProgram;
case 8: Letter = 8; goto StartOfProgram;
case 9: Letter = 9; goto StartOfProgram;
case 10: Letter = 10; goto StartOfProgram;
case 11: Letter = 11; goto StartOfProgram;
case 12: Letter = 12; goto StartOfProgram;
case 13: Letter = 13; goto StartOfProgram;
case 14: Letter = 14; goto StartOfProgram;
case 15: Letter = 15; goto StartOfProgram;
case 16: Letter = 16; goto StartOfProgram;
case 17: Letter = 17; goto StartOfProgram;
case 18: Letter = 18; goto StartOfProgram;
case 19: Letter = 19; goto StartOfProgram;
case 20: Letter = 20; goto StartOfProgram;
case 21: Letter = 21; goto StartOfProgram;
case 22: Letter = 22; goto StartOfProgram;
case 23: Letter = 23; goto StartOfProgram;
case 24: Letter = 24; goto StartOfProgram;
case 25: Letter = 25; goto StartOfProgram;
}
StartOfProgram:
//Start
PORTD = Sequences[Letter][Letter2];
goto Int1;
//Int1 Start
Int1:
if (PORTBbits.RB2 == 0)
{
Int1A:
if (PORTBbits.RB3 != 0)
{
if (PORTBbits.RB2 != 0)
{
Cases++;
if (Cases > 25)
{
Cases = 0;
goto Selections;
}
else
goto Selections;
}
else
goto Int1A;
}
else if (PORTBbits.RB3 == 0)
{
Int1A1:
if (PORTBbits.RB3 != 0)
{
if (Store != 0)
{
Store--;
Seq--;
goto Selections;
}
}
else
goto Int1A1;
}
}
else if (PORTBbits.RB3 == 0)
{
Int1B:
if (PORTBbits.RB3 != 0)
{
Cases --;
if (Cases < 0)
{
Cases = 25;
goto Selections;
}
else
{
goto Selections;
}
}
else
goto Int1B;
}
else if(PORTBbits.RB1 == 0)
{
Int2A:
if (PORTBbits.RB1 != 0)
{
if (PORTBbits.RB3 == 0)
{
StorageArray[Store] = Letter +26; //array holding data
Store++; //array1d value increase
Seq++; //increase total letter by 1
Wait5:
if (PORTBbits.RB3 != 0)
{
goto StartOfProgram;
}
else
goto Wait5;
}
else
{
StorageArray[Store] = Letter; //array holding data
Store++; //array1d value increase
Seq++; //increase total letter by 1
goto StartOfProgram;
}
}
else
goto Int2A;
}
else
{
goto Int3A;
}
Int3A:
if(PORTBbits.RB0 == 0)
{
Int3B:
if(PORTBbits.RB0 != 0)
{
Restore = Store;
Display();
}
else
{
goto Int3B;
}
}
else
goto StartOfProgram;
}
int Display()
{
int x;
int y;
if (Store == 0)
{
Start();
}
if (Store == 1)
{
x = 25;
y = 40;
}
else if (Store == 2)
{
x = 22;
y = 40;
}
else if (Store == 3)
{
x = 15;
y = 10;
}
else if (Store == 4)
{
x = 13;
y = 30;
}
else if (Store > 4)
{
x = 5;
y = 15;
}
//Seq is to allow m to reset to default.
//Store is to store the letter
//StorageArray is to store selected
Store = 0;
Repeat1:
//not yet last letter
if (Store != Seq)
{
Letter = StorageArray[Store];
Repeat2:
if (Letter2 < 8)
{
Delay100TCYx (x);
PORTD = Characters[Letter][Letter2];
Letter2++;
goto IntZ;
}
else if (Letter2 > 7)
{
Store++;
Letter2 = 0;
goto IntZ;
}
}
else
Store = 0;
goto Repeat1;
IntZ:
if (PORTBbits.RB3 == 0)
{
IntZ1:
if (PORTBbits.RB3 != 0)
{
Letter2 = 0;
Store = 0;
Seq = 0;
Cases = 0;
Start();
}
else
goto IntZ1;
}
else
goto Repeat1;
}
Last edited by a moderator: