Commit de6ba790 authored by lcgamboa's avatar lcgamboa

fix: s51 chip draw bug fixed !minor

parent ccf68ec9
...@@ -41,8 +41,9 @@ enum ...@@ -41,8 +41,9 @@ enum
enum enum
{ {
O_LPWR, //Power LED O_LPWR, //Power LED
O_LED, //LED on PC13 output O_MP,
}; };
//return the input ids numbers of names used in input map //return the input ids numbers of names used in input map
unsigned short unsigned short
...@@ -62,8 +63,8 @@ unsigned short ...@@ -62,8 +63,8 @@ unsigned short
cboard_s51::get_out_id(char * name) cboard_s51::get_out_id(char * name)
{ {
if (strcmp (name, "LED") == 0)return O_LED; if (strcmp (name, "O_MP") == 0)return O_MP;
if (strcmp (name, "LPWR") == 0)return O_LPWR; if (strcmp (name, "O_LPWR") == 0)return O_LPWR;
printf ("Error output '%s' don't have a valid id! \n", name); printf ("Error output '%s' don't have a valid id! \n", name);
...@@ -76,21 +77,24 @@ cboard_s51::cboard_s51(void) ...@@ -76,21 +77,24 @@ cboard_s51::cboard_s51(void)
{ {
Proc = "C51"; //default microcontroller if none defined in preferences Proc = "C51"; //default microcontroller if none defined in preferences
ReadMaps (); //Read input and output board maps ReadMaps (); //Read input and output board maps
lxImage image;
image.LoadFile (Window1.GetSharePath () + lxT ("boards/Common/ic40.png"));
micbmp = new lxBitmap (image, &Window1);
} }
//Destructor called once on board destruction //Destructor called once on board destruction
cboard_s51::~cboard_s51(void) cboard_s51::~cboard_s51(void) {
{ delete micbmp;
micbmp = NULL;
} }
//Reset board status //Reset board status
void void
cboard_s51::Reset(void) cboard_s51::Reset(void)
{ {
MReset(1); MReset (1);
//verify serial port state and refresh status bar //verify serial port state and refresh status bar
#ifndef _WIN_ #ifndef _WIN_
...@@ -138,7 +142,7 @@ cboard_s51::WritePreferences(void) ...@@ -138,7 +142,7 @@ cboard_s51::WritePreferences(void)
//write selected microcontroller of board_x to preferences //write selected microcontroller of board_x to preferences
Window1.saveprefs (lxT ("s51_proc"), Proc); Window1.saveprefs (lxT ("s51_proc"), Proc);
//write microcontroller clock to preferences //write microcontroller clock to preferences
Window1.saveprefs (lxT ("s51_clock"), String ().Format ("%2.1f", Window1.GetClock())); Window1.saveprefs (lxT ("s51_clock"), String ().Format ("%2.1f", Window1.GetClock ()));
} }
//Called whe configuration file load preferences //Called whe configuration file load preferences
...@@ -155,7 +159,7 @@ cboard_s51::ReadPreferences(char *name, char *value) ...@@ -155,7 +159,7 @@ cboard_s51::ReadPreferences(char *name, char *value)
//read microcontroller clock //read microcontroller clock
if (!strcmp (name, "s51_clock")) if (!strcmp (name, "s51_clock"))
{ {
Window1.SetClock (atof(value)); Window1.SetClock (atof (value));
} }
} }
...@@ -163,18 +167,14 @@ cboard_s51::ReadPreferences(char *name, char *value) ...@@ -163,18 +167,14 @@ cboard_s51::ReadPreferences(char *name, char *value)
//Event on the board //Event on the board
void void
cboard_s51::EvKeyPress(uint key, uint mask) cboard_s51::EvKeyPress(uint key, uint mask) {
{ }
}
//Event on the board //Event on the board
void void
cboard_s51::EvKeyRelease(uint key, uint mask) cboard_s51::EvKeyRelease(uint key, uint mask) {
{ }
}
//Event on the board //Event on the board
...@@ -223,7 +223,7 @@ cboard_s51::EvMouseButtonPress(uint button, uint x, uint y, uint state) ...@@ -223,7 +223,7 @@ cboard_s51::EvMouseButtonPress(uint button, uint x, uint y, uint state)
Window1.Set_mcurst (1); Window1.Set_mcurst (1);
} }
*/ */
MReset(-1); MReset (-1);
p_MCLR = 0; p_MCLR = 0;
break; break;
} }
...@@ -253,7 +253,7 @@ cboard_s51::EvMouseButtonRelease(uint button, uint x, uint y, uint state) ...@@ -253,7 +253,7 @@ cboard_s51::EvMouseButtonRelease(uint button, uint x, uint y, uint state)
{ {
Window1.Set_mcupwr (1); Window1.Set_mcupwr (1);
Window1.Set_mcurst (0); Window1.Set_mcurst (0);
/* /*
if (reset (-1)) if (reset (-1))
{ {
Reset (); Reset ();
...@@ -276,6 +276,8 @@ void ...@@ -276,6 +276,8 @@ void
cboard_s51::Draw(CDraw *draw, double scale) cboard_s51::Draw(CDraw *draw, double scale)
{ {
int i; int i;
lxRect rec;
lxSize ps;
draw->Canvas.Init (scale, scale); //initialize draw context draw->Canvas.Init (scale, scale); //initialize draw context
...@@ -289,15 +291,28 @@ cboard_s51::Draw(CDraw *draw, double scale) ...@@ -289,15 +291,28 @@ cboard_s51::Draw(CDraw *draw, double scale)
switch (output[i].id)//search for color of output switch (output[i].id)//search for color of output
{ {
case O_LED: //White using pc13 mean value
draw->Canvas.SetColor (pins[1].oavalue, 0 , 0);
break;
case O_LPWR: //Blue using mcupwr value case O_LPWR: //Blue using mcupwr value
draw->Canvas.SetColor (225 * Window1.Get_mcupwr () + 30, 0 ,0 ); draw->Canvas.SetColor (225 * Window1.Get_mcupwr () + 30, 0, 0);
draw->Canvas.Rectangle (1, output[i].x1, output[i].y1, output[i].x2 - output[i].x1, output[i].y2 - output[i].y1);
break;
case O_MP:
lxFont font (
(MGetPinCount () >= 100) ? 9 : ((MGetPinCount () > 14) ? 12 : 10)
, lxFONTFAMILY_TELETYPE, lxFONTSTYLE_NORMAL, lxFONTWEIGHT_NORMAL);
draw->Canvas.SetFont (font);
ps = micbmp->GetSize ();
draw->Canvas.PutBitmap (micbmp, output[i].x1, output[i].y1);
draw->Canvas.SetFgColor (255, 255, 255);
rec.x = output[i].x1;
rec.y = output[i].y1;
rec.width = ps.GetWidth ();
rec.height = ps.GetHeight ();
draw->Canvas.TextOnRect (Proc, rec, lxALIGN_CENTER | lxALIGN_CENTER_VERTICAL);
break; break;
} }
draw->Canvas.Rectangle (1, output[i].x1, output[i].y1, output[i].x2 - output[i].x1, output[i].y2 - output[i].y1);
} }
} }
...@@ -321,7 +336,7 @@ cboard_s51::Run_CPU(void) ...@@ -321,7 +336,7 @@ cboard_s51::Run_CPU(void)
//reset pins mean value //reset pins mean value
memset (alm, 0, 64* sizeof (unsigned int)); memset (alm, 0, 64 * sizeof (unsigned int));
//Spare parts window pre process //Spare parts window pre process
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
class cboard_s51:public board_ucsim class cboard_s51:public board_ucsim
{ {
private: private:
lxBitmap * micbmp;
public: public:
//Constructor called once on board creation //Constructor called once on board creation
cboard_s51(void); cboard_s51(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment