Пример #1
0
//-----------------------------------------------------------------------------
float mglFont::get_ptr(long &i,unsigned *str, unsigned **b1, unsigned **b2,float &w1,float &w2, float f1, float f2, int st) const
{
	static unsigned s1[2]={0,0}, s2[2]={0,0};
	register long k;
	i++;
	if(str[i]==unsigned(-3))
	{
		i++;	*b1 = str+i;
		for(k=1;k>0 && str[i];i++)
		{
			if(str[i]==unsigned(-4))	k--;
			if(str[i]==unsigned(-3))	k++;
		}
		str[i-1]=0;
	}
	else	{	s1[0] = str[i];	*b1 = s1;	i++;	}
	if(str[i]==unsigned(-3))
	{
		i++;	*b2 = str+i;
		for(k=1;k>0 && str[i];i++)
		{
			if(str[i]==unsigned(-4))	k--;
			if(str[i]==unsigned(-3))	k++;
		}
		str[i-1]=0;
	}
	else	{	s2[0] = str[i];	*b2 = s2;	i++;	}
	i--;
	w1 = Puts(*b1, 0, 0, f1, 0x10|st,'k','k');
	w2 = Puts(*b2, 0, 0, f2, 0x10|st,'k','k');
	return w1>w2 ? w1 : w2;
}
Пример #2
0
void Msg_Unreceive(dword last_msg, HMSG hm)
{
  HMSG hmsg;
  XMSG msg;

  if (hm)
    hmsg=hm;
  else if ((hmsg=MsgOpenMsg(sq, MOPEN_RW, last_msg))==NULL)
  {
    Puts(msgnotavail);
    return;
  }

  if (MsgReadMsg(hmsg, &msg, 0L, 0L, NULL, 0L, NULL)==0)
  {
    if (!CanSeeMsg(&msg))
    {
      Puts(msgnotavail);
      MsgCloseMsg(hmsg);
      return;
    }

    msg.attr &= ~MSGREAD;
    MsgWriteMsg(hmsg, TRUE, &msg, NULL, 0L, 0L, 0L, NULL);
  }

  if (!hm)
    MsgCloseMsg(hmsg);

  Puts(WHITE);
  Puts(done_ex);
}
Пример #3
0
//-----------------------------------------------------------------------------
float mglFont::Width(const wchar_t *str,int font) const
{
	if(GetNumGlyph()==0 || !str || *str==0)	return 0;
	float ww=0,w=0;
	size_t size = mgl_wcslen(str)+1;
	if(parse)
	{
		unsigned *wcs = new unsigned[size], *buf=wcs;
		memcpy(wcs,str,size*sizeof(wchar_t));
		Convert(str, wcs);
		for(size_t i=0;wcs[i];i++)	if(wcs[i]=='\n')	// parse '\n' symbol
		{
			wcs[i]=0;	w = Puts(buf,0,0,1.,0x10|font,'k','k');	// find width
			buf=wcs+i+1;	if(w>ww)	ww=w;
		}
		w = Puts(buf,0,0,1.,0x10|font,'k','k');
		if(w<ww)	w=ww;
		delete []wcs;
	}
	else
	{
		int s = (font/MGL_FONT_BOLD)&3;
		for(size_t i=0;i<size;i++)
		{
			long j = str[i]!=' ' ? Internal(str[i]) : Internal('!');
			if(j==-1)	continue;
			w+= GetWidth(s,j)/fact[s];
		}
	}
	return w;
}
Пример #4
0
void Msg_Toggle_Kludges(void)
{
  if (GEPriv(usr.priv, prm.ctla_priv))
    prm.ctla_priv=prm.seenby_priv=(sword)-1;
  else prm.ctla_priv=prm.seenby_priv=usr.priv;

  Puts(WHITE);
  Puts(done_ex);
}
Пример #5
0
static void edit_lang(int nn) {
  int i1;
  languagerec *n;

  out->Cls();
  bool done = false;
  int cp = 0;
  n = &(languages[nn]);
  out->SetColor(Scheme::NORMAL);

  Printf("Language name  : %s\n", n->name);
  Printf("Data Directory : %s\n", n->dir);
  Printf("Menu Directory : %s\n", n->mdir);
  out->SetColor(Scheme::PROMPT);
  Puts("\n<ESC> when done.\n\n");
  out->SetColor(Scheme::NORMAL);
  do {
    out->GotoXY(17, cp);
    switch (cp) {
    case 0:
      editline(n->name, sizeof(n->name) - 1, ALL, &i1, "");
      trimstr(n->name);
#ifdef WHY
      ss = strchr(n->name, ' ');
      if (ss) {
        *ss = 0;
      }
#endif
      Puts(n->name);
      Puts("                  ");
      break;
    case 1:
      editline(n->dir, 60, EDITLINE_FILENAME_CASE, &i1, "");
      trimstrpath(n->dir);
      Puts(n->dir);
      break;
    case 2:
      editline(n->mdir, 60, EDITLINE_FILENAME_CASE, &i1, "");
      trimstrpath(n->mdir);
      Puts(n->mdir);
      break;
    }
    cp = GetNextSelectionPosition(0, 2, cp, i1);
    if (i1 == DONE) {
      done = true;
    }
  } while (!done);
}
Пример #6
0
static int near SendWarnings(PMAH pmah)
{
  /* Make sure that there's (roughly) enough space to save the message */
  
  if ((pmah->ma.type & MSGTYPE_SDM) && zfree(PMAS(pmah, path)) < 10000L)
  {
    Puts(warn_splow);
    Press_ENTER();
  }
  
  /* Warm the user if s/he doesn't have much time left */

  if (timeleft() <= 5)
  {
    Printf(warn_mleft, timeleft());

    if (GetyNAnswer(strt_any, 0)==NO)
      return -1;
  }

  if (AreaIsReadOnly(pmah))
    return -1;

  return 0;
}
Пример #7
0
int main(void) {
    curmudgeon_t *      app = NULL;
    event_t *           event = NULL;
    char *              test = "/hello_world/arg1/arg2";
    if ( cur_init(&app,1) == CUR_OK) {
        app->schema_version_file = "schema.version"; 
        adapter_t * a = NULL;
        db_mysql(app,&a,"{ 'host': 'localhost', 'user': '******', 'pass': '******' }");
        db_connect( a );
        db_select_db( a ,"curmudgeon");
        printf("Schema version is: %d\n",_get_num_from_file(app->schema_version_file));
        _set_num_in_file(app->schema_version_file,1); 
        printf("Schema version is: %d\n",_get_num_from_file(app->schema_version_file));
        if ( schema_database(a,"test_table",NULL,NULL) == CUR_OK ) {
            printf("migrated\n");
        } else {
            printf("did not migrate\n");
        }
        _set_num_in_file(app->schema_version_file,0); 
        if ( schema_database( a ,"test_table",NULL,NULL) == CUR_OK ) {
            printf("migrated\n");
        } else {
            printf("did not migrate\n");
        }
        schema_database( a ,"test_table","latin1","latin1_general_ci");
        cur_done(&app);
    } else {
        Puts("Could not init");
    }
    return 0;
}
Пример #8
0
int main(void) {
    curmudgeon_t *      app = NULL;
    event_t *           event = NULL;
    char *              test = "/hello_world/arg1/arg2";
    if ( cur_init(&app,1) == CUR_OK) {
        cur_register_event(&app,"hello_world.*", 0,hello_world);
        cur_parse_request(test,&event);
        cur_call_handler(app,&event);


        regex_t * re = NULL;
        // - is the escape character because \\ is to messy and ugly. and -- in
        // char classes does not make them less readable
        cur_regex(&re,"/^-/hello_(?P<wor>world)(?P<another>-/something)-/(?P<else>.*)/i");
        int rc = cur_match(&re,"/hello_world/something/aboutelse",0);
        if ( rc == CUR_OK ) {
            int i;
            for (i = 0; i <= re->captc; i++) {
                printf("Nummed: %d -> %s\n",i,re->capt(re,i));
            }
        } else {
            printf("it did not match %d\n",rc);
        }
        printf("named search: %s\n",re->named(re,"else"));
        printf("nummed search: %s\n",re->capt(re,3));
        // Cannot resuse the same regex, because PCRE is smart and remembers it an tries to reuse it
        cur_free_regex(&re);
        cur_done(&app);
    } else {
        Puts("Could not init");
    }
    return 0;
}
Пример #9
0
void InitHostCore(BYTE fPowerUpBoot)
{
	if(fPowerUpBoot) {
		//check port 1.5. if high, it is a skip(NoInit) mode.
		SysNoInitMode = SYS_MODE_NORMAL;
#ifdef MODEL_TW8836FPGA
		if(1)	
#else
		if(PORT_NOINIT_MODE == 1)	
#endif
		{
			SysNoInitMode = SYS_MODE_NOINIT;
			//turn on the SKIP_MODE.
			access = 0;
					
			McuSpiClkSelect(MCUSPI_CLK_27M);
			return;
		}
	}

	Puts("\nInitHostCore");	
	//----- Set SPI mode
	SpiFlashVendor = SPIHost_QUADInit();
	SPIHost_SetReadModeByRegister(SPI_READ_MODE);		// Match DMA READ mode with SPI-read

	//----- Enable Chip Interrupt

	WriteHostPage(PAGE0_GENERAL );
	WriteHost(REG002, 0xFF );	// Clear Pending Interrupts
	WriteHost(REG003, 0xFE );	// enable SW. disable all other interrupts

	//enable remocon interrupt.
	EnableRemoInt();
}
Пример #10
0
//-----------------------------------------------------------------------------
float mglFont::Puts(const char *str,const char *how,float c1,float c2) const
{
	int font=0, align=1;	float w=0;
	mglGetStyle(how,&font,&align);
	MGL_TO_WCS(str,w = Puts(wcs,font,align,c1,c2));
	return w;
}
Пример #11
0
float mglFont::Puts(const unsigned *text, float x,float y,float f,int style,float c1,float c2) const
{
	if(GetNumGlyph()==0)	return 0;
	float w=0;				// string width
	int st = style;			// current style
	unsigned *b1, *b2;		// pointer to substring
	unsigned *str;			// string itself
	float yy=y, ff=f, ww, w1, w2;
	int a = (st/MGL_FONT_BOLD)&3;
	long i;
	for(i=0;text[i];i++);
	float dc=i>1?(c2-c1)/(i-1):0;
	str = new unsigned[i+1];
	memcpy(str,text,(i+1)*sizeof(unsigned));

	float ccol = 0;
	for(long i=0;str[i];i++)
	{
		ccol = ccol<0?ccol:c1+dc*i;
		unsigned s = str[i];		ww = 0;
		if(s==unsigned(-3))	// recursion call here
		{
			i++;	b1 = str+i;
			for(long k=1;k>0 && str[i];i++)
			{
				if(str[i]==unsigned(-4))	k--;
				if(str[i]==unsigned(-3))	k++;
			}
			str[i-1]=0;	i--;
			ww = Puts(b1, x, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol,ccol);
			if(gr && !(style&0x10))	// add under-/over- line now
				draw_ouline(st,x,y,f,fact[a],ww,ccol);
			MGL_CLEAR_STYLE
		}
		else if(s=='\n')	// newline
Пример #12
0
void loop(){ // run over and over again
	int i;  
	startMillis = millis();
  
	SelectFont(System5x7, BLACK);       // select fixed width system font
	while( millis() - startMillis < 1000){ 		// loop for one second
    DrawRect(0, 0, 64, 61, BLACK); 				// rectangle in left side of screen
    DrawRoundRect(68, 0, 58, 61, 5, BLACK);  	// rounded rectangle around text area   
    for(i=0; i < 62; i += 4)
      DrawLine(1,1,63,i, BLACK);  				// draw lines from upper left down right side of rectangle  
    DrawCircle(32,31,30,BLACK);   				// draw circle centered in the left side of screen  
    FillRect(92,40,16,16, WHITE); 				// clear previous spinner position  
    CursorTo(3,4);               				// locate curser for printing text
    GotoXY(29,40);								// use GotoXY for truetype fonts
    PrintNumber(++iter);         				// print current iteration at the current cursor position
  }

  SelectFont(Arial_Bold_14, BLACK); 	// select truetype font
//
  ClearScreenX();               		// clear the screen  
//
  GotoXY(75,24);						// use GotoXY for truetype fonts
  Puts("FPS= ");             			// print a text string  
  PrintNumber(iter);         			// print a number  
  iter = 0;
 }
Пример #13
0
int main(int argc, char **argv) {
	
	// Compute the size of the screen
	int pixelX = 320;
	int pixelY = 256;
	
	int fontSize = 1; // 0=6x8   1=8x8
	
	GetWeather();

	LCD_screen_init(pixelX,pixelY, fontSize);
	
	// MODE SET
	LCD_mode( MODE_OR ); 
	
	// DISPLAY MODE
	//LCD_display_mode( DM_TEXT + DM_GRAPHICS );
	LCD_display_mode( DM_GRAPHICS );

	int i;
	
	// Erase graphic screen
	LCD_set_address_pointer( LCD_getBaseGraphic() );
	LCD_auto_write_start();
	for (i=0;i<LCD_getGraphicScreenSize();i++) {
		LCD_auto_write( 0x00 ); 
	}
	LCD_auto_write_stop();
	LCD_set_address_pointer( LCD_getBaseText() );
	
	char buffer[256];

	Puts(1,122, "Raspberry Pi LCD - by joaquim.org");

	// current date/time based on current system
   	
   	time_t now = time(0);
   	struct tm *tm_struct = localtime(&now);

   	sprintf(buffer,"%02d:%02d",tm_struct->tm_hour, tm_struct->tm_min);

	WriteText(45, 20, buffer, 2);

	sprintf(buffer,"%s %d %s %04d",weekday[tm_struct->tm_wday], tm_struct->tm_mday, month[tm_struct->tm_mon], 1900 + tm_struct->tm_year);

	WriteText(5, 2, buffer, 1);

	WriteText(5, 50, meteo_ico, 3);	
	WriteText(30, 50, "'", 3);
	sprintf(buffer,"%s/%s", meteo_min, meteo_max);
	WriteText(50, 55, buffer, 1);
	WriteText(85, 49, "*", 3);

	WriteText(1, 75, meteo_obs, 1);
	
	return 0;		

} // main
Пример #14
0
 void Nil(void * p, const char * s) {
     if (p == NULL) {
         // We can't seem to throw errors...weird..
         std::string e;
         ExceptionToMessage(666,e);
         e += " ";
         e += s;
         Puts(e);
         assert(false);
     }
 }
Пример #15
0
void MonitorChipTest_Info(void)
{
	Puts("\n  === Help for ChipTest command ===");
	Puts("\nCTest reg rw		;register read/write test");
	Puts("\nCTest reg default	;register default value");
	Puts("\nCTest gpio			;gpio test");
	Puts("\nCTest sosdlut		;SpiOSD LUT readback test");
	Puts("\nCTest dma [n_wait]	;spiflash dma wait test");
	Puts("\nCTest resume		;power suspend resume");
}
Пример #16
0
/**
* turn on DCDC
*
*	DCDC startup step
*	SSPLL ON
*	FP PWC ON
*	call DCDC_on(0) & DCDC_on(1)
*	delay
*	wait VBlank
*	Enable FP Data Out
*	delay
*	call DCDC_on(2)
*	FP Bias On
*
* DCDC data out needs more then 200ms delay after SSPLL_PowerUp(ON).
*/
BYTE DCDC_StartUP_sub(void)
{
	BYTE ret;

	//-------------
	//FPPWC ON
	FP_PWC_OnOff(ON);

	//ret=DCDC_On(0);
	//ret=DCDC_On(1);

	//-------------
	// wait
#ifdef TW8835_EVB_10
	delay1ms(100);
#endif

	WaitVBlank(1);
	//-------------
	//FP Data Out
	OutputEnablePin(ON,ON);		//Output enable. FP data: enable


#ifdef TW8835_EVB_10
	delay1ms(15);
#endif

	//DCDC final
	//ret=DCDC_On(2);
	ret=ERR_SUCCESS;

	//-------------
	//FPBIAS ON 
	FP_BiasOnOff(ON);

	//disable Blank
	//WriteTW88Page(PAGE2_SCALER);
	//WriteTW88(REG21E, ReadTW88(REG21E) & ~0x01);

//	PrintSystemClockMsg("DCDC_StartUp END");
	if(ret!=ERR_SUCCESS) {
		Puts(" FAIL");

		//WriteTW88Page(PAGE0_DCDC);
		//WriteTW88(REG0E8, 0xF2);	Printf("\nREG0E8:F2[%bd]",ReadTW88(REG0EA)>>4);
		//WriteTW88(REG0E8, 0x02);	Printf("\nREG0E8:02[%bd]",ReadTW88(REG0EA)>>4);
		//WriteTW88(REG0E8, 0x03);	Printf("\nREG0E8:03[%bd]",ReadTW88(REG0EA)>>4);
		//WriteTW88(REG0E8, 0x01);	Printf("\nREG0E8:01[%bd]",ReadTW88(REG0EA)>>4);
		//WriteTW88(REG0E8, 0x11);	Printf("\nREG0E8:11[%bd]",ReadTW88(REG0EA)>>4);
		//WriteTW88(REG0E8, 0x71);	Printf("\nREG0E8:71[%bd]",ReadTW88(REG0EA)>>4);
	}
	return ret;
}
Пример #17
0
int GetMsgAttr(XMSG *msg, PMAH pmah, char *mname, long mn, long highmsg)
{
  int ret;

  /* If users are supposed to put their real names in this conference,      *
   * then do so.                                                            */
     
  if (pmah->ma.attribs & MA_REAL)
  {
    memset(msg->from, 0, sizeof msg->from);
    strcpy(msg->from, usr.name);
  }
  else if ((pmah->ma.attribs & MA_ALIAS) && *usr.alias)
  {
    memset(msg->from, 0, sizeof msg->from);
    strcpy(msg->from, usr.alias);
  }

  /* Clear the keyboard buffer */
  
  Clear_KBuffer();

  /* Warn user about lack of disk space, no time left, and if area is       *
   * read-only.                                                             */
  
  if (SendWarnings(pmah)==-1)
    return -1;
  
  ret=0;

  /* We can accept high bits in the message header */

  in_msghibit++;

  /* Only fix the private flag if we're NOT doing a C)hange message */

  if (mn==0)
    FixPrivateStatus(msg, pmah);

  Puts(enter_header_init);

  /* Now get the main portion of the message header */

  ret=(usr.video ? GetGraphicsHeader : GetTTYHeader)(msg, pmah, mname,
                                                     mn, highmsg);

  in_msghibit--;

  return (ret==-1 ? -1 : IsHeaderOkay(msg, pmah));
}
Пример #18
0
int CheckCredit(NETADDR *dest, PMAH pmah)
{
  NFIND *nf;
  int cost;

  if (! (pmah->ma.attribs & MA_NET))
    return 0;
  
  if ((nf=NodeFindOpen(dest))==NULL)
  {
    if (! GEPriv(usr.priv, prm.unlisted_priv))
    {
      Puts(unlisteddest);
      Press_ENTER();
      return -1;
    }

    cost=prm.unlisted_cost;
  }
  else
  {
    cost=nf->found.cost;
    NodeFindClose(nf);
  }

  if (mailflag(CFLAGM_NETFREE))
    cost=0;

  if (usr.debit+cost > usr.credit)
  {
    Puts(ncredit);
    Press_ENTER();
    return -1;
  }

  return 0;
}
Пример #19
0
//-----------------------------------------------------------------------------
float mglFont::Puts(const wchar_t *str,int font,int align, float c1,float c2) const
{
	if(GetNumGlyph()==0 || !str || *str==0)	return 0;
	float ww=0,w=0,h = (align&4) ? 500./fact[0] : 0;
	size_t size = mgl_wcslen(str)+1,num=0;
	if(parse)
	{
		unsigned *wcs = new unsigned[size], *buf=wcs;
		memcpy(wcs,str,size*sizeof(wchar_t));
		Convert(str, wcs);
		for(size_t i=0;wcs[i];i++)
		{
			if(wcs[i]=='\n')	// parse '\n' symbol
			{
				wcs[i]=0;	w = Puts(buf,0,0,1.f,0x10|font,c1,c2);	// find width
				Puts(buf,-w*(align&3)/2.f,-h - 500.*num/fact[0],1.f,font,c1,c2);	// draw it really
				buf=wcs+i+1;	num++;	if(w>ww)	ww=w;
			}
			if(wcs[i]=='\\' && wcs[i+1]=='n' && (wcs[i+2]>' ' || wcschr(L"{}[]()!@#$%^&*/-?.,_=+\\\"", wcs[i+2])))	// parse '\n' symbol
			{
				wcs[i]=0;	w = Puts(buf,0,0,1.f,0x10|font,c1,c2);	// find width
				Puts(buf,-w*(align&3)/2.f,-h - 500.*num/fact[0],1.f,font,c1,c2);	// draw it really
				buf=wcs+i+2;	num++;	if(w>ww)	ww=w;
			}
		}
		// draw string itself
		w = Puts(buf,0,0,1.f,0x10|font,c1,c2);	// find width
		Puts(buf,-w*(align&3)/2.f,-h - 500.*num/fact[0],1.f,font,c1,c2);	// draw it really
		if(w>ww)	ww=w;
		delete []wcs;
	}
	else
	{
		int s = (font/MGL_FONT_BOLD)&3;
		h *= fact[0]/fact[s];
		for(size_t i=0;i<size;i++)		// find width
		{
			long j = str[i]!=' ' ? Internal(str[i]) : Internal('!');
			if(j==-1)	continue;
			w+= GetWidth(s,j)/fact[s];
		}
		ww = w;		w *= -(align&3)/2.f;
		if(gr)	for(size_t i=0;i<size;i++)		// draw it
		{
			long j=0;	//Internal('!');
			if(str[i]!=' ')
			{
				j = Internal(str[i]);
				if(j==-1)	continue;
				gr->Glyph(w, -h, 1, (s+(font&MGL_FONT_WIRE))?4:0, j, c1+i*(c2-c1)/(size-1));
			}
			w+= GetWidth(s,j)/fact[s];
		}
	}
	return ww;
}
Пример #20
0
static void near BadBarPwd(char *pwd, char *name, int tries)
{
  logit(log_bad_bar_pwd, name, pwd);

  Printf(wrong_pwd, tries);
  Putc('\n');

  if (tries==3)
  {
    logit(l_invalid_pwd);
    Puts(invalid_pwd);
    ci_barricade();
    mdm_hangup();
  }
}
Пример #21
0
int CIPMessage::RecMessagePort(HWND hw, int id)
{

	char acRetData[4096];
	int iStat = 0;

	iStat = recv(conn, acRetData, 4096, 0);
	if (iStat == -1)
		return 1;
	//in = acRetData;
	// cout이 아니라 텍스박스 보낼 메세지
	//cout << "-->" << acRetData << "\n";
	Puts(hw, id, acRetData);
	return 0;

}
Пример #22
0
void ChipTest_GPIO(void)
{
	DECLARE_LOCAL_page
	BYTE prev_en,prev_oe,prev_od;
	BYTE value;
	BYTE i;
	BYTE result;

	ReadTW88Page(page);
	WriteTW88Page(0);
	//GPIO0~6
	for(i=0; i < 7; i++) {
		result = ERR_SUCCESS;
		Printf("\nGPIO_%01bxx ",i);
		//read previous value
		prev_en = ReadTW88(REG080+i);
		prev_oe = ReadTW88(REG088+i);
		prev_od = ReadTW88(REG090+i);
		value = ReadTW88(REG098+i);
		Printf("PREV EN:%02X OE:%02X OD:%02X ID:%02X ", prev_en,prev_oe,prev_od,value);

		WriteTW88(REG080+i, 0xFF & GPIO_mask[i]);  		//enable GPIO
		WriteTW88(REG088+i, 0xFF & GPIO_mask[i]);  		//output enable
		WriteTW88(REG090+i, 0xFF & GPIO_mask[i]);  		//output data
		value= ReadTW88(REG098+i) & GPIO_mask[i];		//read input
		Printf(" W:%02bx R:%02bx ",0xFF & GPIO_mask[i], value);
		if((0xFF & GPIO_mask[i]) != (value & GPIO_mask[i])) 
			result = ERR_FAIL;


		WriteTW88(REG090+i, 0x00);  					//output data
		value=ReadTW88(REG098+i) & GPIO_mask[i];		//read input
		Printf(" W:00 R:%02bx ",value);
		if((value & GPIO_mask[i])) 
			result = ERR_FAIL;

		if(result==ERR_SUCCESS)
			Puts(" Pass");

		//restore orginal value
		WriteTW88(REG080+i, prev_en);
		WriteTW88(REG088+i, prev_oe);
		WriteTW88(REG090+i, prev_od);
	}
	WriteTW88Page(page);
}
Пример #23
0
word Shall_We_Continue(word timeout, char *do_what)
{
  word pause, ret;
  int ch;

  long tmr;

  ret=TRUE;

  Putc('\n');
  
  Printf(pause_msg, pause=timeout, do_what);
    
  while (pause-- > 0)
  {
    Printf(pause_time, pause);
    
    tmr=timerset(100);

    vbuf_flush();

    while (!timeup(tmr) && !Mdm_keyp())
      Giveaway_Slice();

    if (Mdm_keyp())
    {
      ch=Mdm_getcw();
      
      if (ch=='\x0d')       /* C/R */
        break;
      else if (ch=='\x1b')  /* ESC */
      {
/*        Puts(xferaborted);*/
        ret=FALSE;
        break;
      }
    }
  }

  Puts("\r" CLEOL);
  WhiteN();
  return ret;
}
Пример #24
0
void Console::Append(const String& s) {
	if(s.IsEmpty()) return;
	if(console) {
		String t = Filter(s, sCharFilterNoCr);
		if(*t.Last() == '\n')
			t.Trim(t.GetCount() - 1);
		Puts(t);
		return;
	}
	int l, h;
	GetSelection(l, h);
	if(GetCursor() == GetLength()) l = -1;
	EditPos p = GetEditPos();
	SetEditable();
	MoveTextEnd();
	WString t = Filter(s, sAppf).ToWString();
	int mg = sb.GetReducedViewSize().cx / GetFont().GetAveWidth();
	if(wrap_text && mg > 4) {
		int x = GetColumnLine(GetCursor()).x;
		WStringBuffer tt;
		const wchar *q = t;
		while(*q) {
			if(x > mg - 1) {
				tt.Cat('\n');
				tt.Cat("    ");
				x = 4;
			}
			x++;
			if(*q == '\n')
				x = 0;
			tt.Cat(*q++);
		}
		Paste(tt);
	}
	else
		Paste(t);
	SetReadOnly();
	if(l >= 0) {
		SetEditPos(p);
		SetSelection(l, h);
	}
}
Пример #25
0
void loop(){ // run over and over again
int i;
  startMillis = millis();
  while( millis() - startMillis < 1000){ // loop for one second
    DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen
    DrawRoundRect(68, 0, 58, 61, 5, BLACK);  // rounded rectangle around text area   
    for(i=0; i < 62; i += 4)
      DrawLine(1,1,63,i, BLACK);  // draw lines from upper left down right side of rectangle  
    DrawCircle(32,31,30,BLACK);   // draw circle centered in the left side of screen  
    FillRect(92,40,16,16, WHITE); // clear previous spinner position  
    CursorTo(5,5);               // locate curser for printing text
    PrintNumber(++iter);         // print current iteration at the current cursor position 
  } 
//
  ClearScreenX();               // clear the screen  
  CursorTo(13,2);              // positon cursor  
  Puts("FPS= ");               // print a text string  
  PrintNumber(iter);           // print a number 
  iter=0;
 }
Пример #26
0
void AreaError(int err)
{
  Puts(err_entering_msg_area);

  switch (err)
  {
    case MERR_NOENT:  Puts(areadoesntexist); break;
    case MERR_NOMEM:  Puts(merr_nomem);   break;
    case MERR_NODS:   Puts(merr_nods);    break;
    case MERR_NOLOCK: Puts(merr_nolock);  break;
    case MERR_SHARE:  Puts(merr_share);   break;
    case MERR_BADH:
    case MERR_BADF:
    case MERR_BADA:
    case MERR_EOPEN:  Puts(merr_corrupt); break;
    default:
    case MERR_NONE:   Printf(merr_unknown, err);  break;
  }

  Putc('\n');
  Press_ENTER();
}
Пример #27
0
/**
* turn on DCDC
*
* @see DCDC_StartUP_sub
*/
BYTE DCDC_StartUP(void)
{
	BYTE ret;
	
	Puts("\nDCDC_StartUP start1");
	ret=DCDC_StartUP_sub();
	if(ret == ERR_SUCCESS) {
		Puts("\nDCDC_StartUP SUCCESS");
		return ERR_SUCCESS;
	}

	Puts("\nDCDC_StartUP start2");
	ret=DCDC_StartUP_sub();
	if(ret == ERR_SUCCESS) {
		Puts("\nDCDC_StartUP SUCCESS");
		return ERR_SUCCESS;
	}
	Puts("\nDCDC_StartUP start3");
	ret=DCDC_StartUP_sub();
	if(ret == ERR_SUCCESS)
		Puts("\nDCDC_StartUP SUCCESS");
	return ret;
}
Пример #28
0
//=============================================================================
//
//=============================================================================
void MonitorMCU(void)
{
	BYTE ret, i, j;
	BYTE idx;
	 
	BYTE argv_num1, argv_num2; //, argv_num3;

	//if ( argc>2) {						 BKFYI: It will hurt a speed
	//	argv_num1 = a2h( argv[2] );
	//	if ( argc>3 ) {
	//		argv_num2 = a2h( argv[3] );
	//		if (argc > 4) {
	//			argv_num3 = a2h( argv[4] );
	//		}
	//	}
	//}

	//---------------------- Write SFR -----------------------
	if( !stricmp( argv[1], "Ws" ) ) {
		if( argc < 4 ) {
			Printf(" ----> Missing parameter !!!");
			return;
		}
		argv_num1 = a2h( argv[2] );
		argv_num2 = a2h( argv[3] );
		ret = WriteSFR(argv_num1, argv_num2);
		if( echo ) {
			Printf("\nMCU SFR Write: %02bx=%02bx (%02bx) ", argv_num1, argv_num2, ret);
			for(i=0; i<8; i++) {
				if( ret & 0x80 ) Puts("1"); else Puts("0");
				ret <<=1;
			}
		}
	}

	//---------------------- Read SFR ------------------------
	else if( !stricmp( argv[1], "Rs" ) ) {
		if( argc < 3 ) {
			Printf(" ----> Missing parameter !!!");
			return;
		}
		argv_num1 = a2h( argv[2] );
		ret = ReadSFR(argv_num1);
		if( echo ) {
			Printf("\nMCU SFR Read: %02bx=%02bx ", argv_num1, ret);
			for(i=0; i<8; i++) {
				if( ret & 0x80 ) Puts("1"); else Puts("0");
				ret <<=1;
			}
		}
	}

	//---------------------- Dump SFR ------------------------
	else if( !stricmp( argv[1], "Ds" ) ) {

		Printf("\nDump DP8051 SFR");
		for (j=0x8; j<=0x0f; j++) {
			Printf("\nSFR %02bx: ", j*0x10);
			for(i=0; i<8; i++) Printf("%02bx ", ReadSFR(j*0x10+i) );
			Printf("- ");
			for(; i<16; i++) Printf("%02bx ", ReadSFR(j*0x10+i) );
		}

	}
	//---------------------- Bitwise SFR control---------------------
	else if( !stricmp( argv[1], "Bs" ) ) {
		Printf("\nSorry!!");
	}
	//---------------------- Dump SFR map---------------------
	else if( !stricmp( argv[1], "SFR" ) ) {
		BYTE len;

		DWORD UsedTime;
		UsedTime = SystemClock;

		Printf("\nDump DP80390 SFR");



		for(j=0x00; j < 0x80; j++) {
			idx = j+0x80;
			for(i=0; i < 0x80; i++) {
				if(SFR_map[i].idx == idx)
					break;	//success
				if(SFR_map[i].idx == 0) {
					i = 0x80;
					break;  //fail
				}
			}
			if((j&0x07) == 0)
				Puts("\n");
			if(i != 0x80) {
				Printf("%02bx:%05s",SFR_map[i].idx, SFR_map[i].name);
				len = TWstrlen(SFR_map[i].name);
				len = 5-len;  //max 5.
				for(i=0; i < len; i++)
					Puts(" ");
				Printf(":%02bx ",ReadSFR(idx));
			}
			else {
			  //Printf("--:-----:--_");   
			  //Printf("            ");   
				Printf("   .....    ");   
			}
		}
		UsedTime = SystemClock - UsedTime;
		Printf("\nUsedTime:%ld.%ldsec", UsedTime/100, UsedTime%100 );

	}
	//---------------------- Dump xdata ----------------------
	else if( !stricmp( argv[1], "Wx" ) ) {

		WORD addr;

		if( argc < 4 ) {
			Printf(" ----> Missing parameter !!!");
			return;
		}
		addr      = a2h( argv[2] );
		argv_num2 = a2h( argv[3] );
		
		*(BYTE xdata *)(addr) = argv_num2;
		ret = *(BYTE xdata *)(addr);
		
		if( echo ) {
			Printf("\nMCU XDATA Write: %04x=%02bx (%02bx) ", addr, argv_num2, ret);
		}
	}

	//---------------------- Dump xdata ----------------------
	else if( !stricmp( argv[1], "Rx" ) ) {

		WORD addr;

		if( argc < 3 ) {
			Printf(" ----> Missing parameter !!!");
			return;
		}
		addr = a2h(argv[2]);

		ret = *(BYTE xdata *)(addr);

		if( echo ) {
			Printf("\nMCU XDATA Read: %04x=%02bx ", addr, ret);
		}
	}

	//---------------------- Dump xdata ----------------------
	else if( !stricmp( argv[1], "Dx" ) ) {

		//data BYTE xdata *osddata = (BYTE xdata *)0xc002;

		WORD addr=0x0000, len=0x100;

		if( argc>=3 ) addr = a2h(argv[2]);
		if( argc>=4 ) len  = a2h(argv[3]);

		Printf("\nDump DP8051 XDATA 0x%04x ", addr);
		for (j=0; j<len/0x10; j++) {
			Printf("\nXDATA %04x: ", (WORD)(addr+j*0x10) );
			for(i=0; i<8; i++) Printf("%02bx ", *(BYTE xdata *)(addr + j*0x10+i) );
			Printf("- ");
			for(; i<16; i++) Printf("%02bx ", *(BYTE xdata *)(addr + j*0x10+i) );
		}

	}

	//---------------------- Enable WDT ------------------------
#if defined(SUPPORT_WATCHDOG) || defined(DEBUG_WATCHDOG)
	else if( !stricmp( argv[1], "WDT" ) ) {
		if(argc > 2) {
			if( argv[2][0]=='1' ) {
				BYTE mode;
				if(argc > 3) 
					mode=a2h(argv[3]);
				else	
					mode = 0;

				EnableWatchdog(mode);
				Printf("\nWatchdog Timer is enabled. mode:%bx", mode);
			}
			else if( argv[2][0]=='2' ) {
				Puts("Watchdog test....");
				RestartWatchdog();
				Puts("start....");
				SFR_EWDI = 0;

				delay1s(1,__LINE__);
				delay1s(1,__LINE__);
				delay1s(1,__LINE__);
				delay1s(1,__LINE__);
				delay1s(1,__LINE__);
				delay1s(1,__LINE__);
				delay1s(1,__LINE__);
				//system reset before you here.
				Puts("..FAIL");
			}
			else {
				DisableWatchdog();
				Printf("\nWatchdog Timer is disabled.");
			}
		}
		else {
			Puts("\nWatchdog ");
			if(SFR_WDCON & 0x02) Puts("On");
			else                 Puts("Off");
#ifdef SUPPORT_WATCHDOG
			Puts(" with SUPPORT_WATCH");
#endif
#ifdef DEBUG_WATCHDOG
			Puts(" with DEBUG_WATCH");
#endif
		}

	}
#endif
	//---------------------- Enable INT ------------------------
	else if( !stricmp( argv[1], "IE" ) ) {
		if ( argc < 3 ) {
			Puts("\nMCU IE n 1/0 - MCU interrupt en/disable #n ");
			return;
		}
		argv_num1 = a2h( argv[2] );

		if( argv[3][0]=='1' ) {
			EnableExtInterrupt( argv_num1 );
			Printf("\nInterrupt #%d is enabled.", argv_num1);
		}
		else {
			DisableExtInterrupt( argv_num1 );
			Printf("\nInterrupt #%d is disabled.", argv_num1);
		}
	}
	//---------------------- Extended INT ------------------------
	else if( !stricmp( argv[1], "DE" ) ) {
		Printf("\nEnable DE-end Interrupt");
		SFR_IE1 = 0;	// Clear Pending Interrupt
		SFR_EX1 = 1;	// Enable Interrupt
	}
	//---------------------- Extended INT ------------------------
	else if( !stricmp( argv[1], "EI" ) ) {
	extern DWORD ExtIntCount;
		if( argc < 3 ) {
			Printf("\nMCU extend Interrupt Status: %02bx, count: %ld", EXINT_STATUS, ExtIntCount );
			ExtIntCount = 0;
#ifdef DEBUG_ISR
			Printf(" MCU %04x", MCU_INT_STATUS);
			MCU_INT_STATUS = 0;
#endif
			return;
		}
		argv_num1 = a2h( argv[2] );

		EXINT_STATUS &= argv_num1;
		
	}
	//---------------------- INTERRUPT Counter---------------------
#ifdef DEBUG_ISR
	else if( !stricmp( argv[1], "INTC" ) ) {
		BYTE i;
		WORD counter;
		for(i=0; i <= 20; i++) {
			SFR_EA=0;
			counter = INTR_counter[i];	//read
			INTR_counter[i]=0;			//clear
			SFR_EA=1;
			
			if(counter) {
				Printf("\n%02bd:%d",i,counter);
			}
		}
	}
#endif
#ifdef DEBUG_UART
	else if( !stricmp( argv[1], "UART" ) )
		DEBUG_dump_uart0();
#if 0
		 {
		BYTE i;
		if(UART0_OVERFLOW_counter) {
			Printf("\nUART0 Overflow:%bd",UART0_OVERFLOW_counter);
			UART0_OVERFLOW_counter = 0;  //clear
		}
		if(UART0_MAX_counter) {
			Printf("\nUART0 Max:%bd",UART0_MAX_counter);
			UART0_MAX_counter = 0;  //clear
		}
		Printf("\nRS_buf[%bd], RS_in:%bd RS_out:%bd",RS_BUF_MAX,RS_in,RS_out);
		for(i=0; i <  RS_BUF_MAX; i++)
			Printf(" %02bx", RS_buf[i]);
	}
#endif
#endif

	//---------------------- Interrupt Help ------------------------
	else if( !stricmp( argv[1], "INT" ) ) {
Пример #29
0
//=============================================================================
//			Help Message
//=============================================================================
void MCUHelp(void)
{

	Puts("\n=======================================================");
	Puts("\n>>>     Welcome to Intersil Monitor  Rev 1.00     <<<");
	Puts("\n=======================================================");
	Puts("\n   MCU Rs ii             ; Read SFR");
	Puts("\n   MCU Ws ii dd          ; Write SFR");
	Puts("\n   MCU Ds                ; Dump SFR");
	Puts("\n   MCU Bs ii se dd       ; bitwise SFR. s:start bit, e:end bit");
	Puts("\n   MCU sfr               ; Dump SFR map");
	Puts("\n   MCU Rx ii             ; Read XDATA");
	Puts("\n   MCU Wx ii dd          ; Write XDATA");
	Puts("\n   MCU Dx [ii] [cc]      ; Dump XDATA");
#if defined(SUPPORT_WATCHDOG) || defined(DEBUG_WATCHDOG)
	Puts("\n   MCU WDT [0/1/2]       ; WatchDog disable/enable/test");
#endif
	Puts("\n   MCU stop              ; stop mode");
	Puts("\n   MCU IE n              ; enable interrupt");
	Puts("\n   MCU DE n              ; disable interrupt");
	Puts("\n   MCU EI [n]            ; extended interrupt");
	Puts("\n   MCU INT               ; help interrupt");
	Puts("\n");

}
Пример #30
0
void ChipTest_Register_RW(BYTE page)
{
	BYTE *pDefData, *pWMask, *pRMask, Mask;
	BYTE i,j,Index;
	WORD PageIndex;
	BYTE prev_data;
	volatile BYTE value;

	//link data
	switch(page) {
	case 0: pDefData = DefPage0Regs; pWMask = RegMask_W_Page0; pRMask = RegMask_R_Page0;	break;
	case 1: pDefData = DefPage1Regs; pWMask = RegMask_W_Page1; pRMask = RegMask_R_Page1;	break;
	case 2: pDefData = DefPage2Regs; pWMask = RegMask_W_Page2; pRMask = RegMask_R_Page2;	break;
	case 3: pDefData = DefPage3Regs; pWMask = RegMask_W_Page3; pRMask = RegMask_R_Page3;	break;
	case 4: pDefData = DefPage4Regs; pWMask = RegMask_W_Page4; pRMask = RegMask_R_Page4;	break;
	case 5: pDefData = DefPage5Regs; pWMask = RegMask_W_Page5; pRMask = RegMask_R_Page5;	break;
	}
	Printf("\nPage:%bd================", page);
	for(i=0; i < 16; i++ ) {
		for(j=0; j < 16; j++) {
			//default value check
			Index = i*16+j;
			PageIndex = ((WORD)page << 8) + Index;
			Mask = pWMask[Index] | pRMask[Index];
			if(pWMask[Index]) {
				Printf("\nREG%01bx%02bx WMask:%02bx RMask:%02bx Def:%02bx",page, Index, pWMask[Index], pRMask[Index], pDefData[Index]);

				value = ReadTW88(PageIndex);
	
				if((value & Mask) != (pDefData[Index] & Mask)) {
					Printf(" Read:%02bx", value);
				}
			}
			else if(pRMask[Index]) {
				//read only.
				Printf("\nREG%01bx%02bx WMask:%02bx RMask:%02bx Def:__",page, Index, pWMask[Index], pRMask[Index]);

				value = ReadTW88(PageIndex);
				Printf(" Read:%02bx", value);
			}
			else if(pDefData[Index]==0xBF) {
				value = ReadTW88(PageIndex);
				if(value != 0xBF) {
					Printf("\nREG%01bx%02bx BF. Read:%02bx", page, Index, value);

					WriteTW88(PageIndex, 0xFF);
					value = ReadTW88(PageIndex);
					if(value != 00) {
						Printf("\nREG%01bx%02bx BF. but writable.", page, Index);
					}
				}
				else {
					//assume NO register.
				}
			}

			//skip
			if(PageIndex == REG4E1)	{ //it is a clock
				Puts("->skip");
				continue;
			}

			//write test
			if(pWMask[Index]) {
				prev_data = ReadTW88(PageIndex);

				WriteTW88(PageIndex, 0x00);
				value = ReadTW88(PageIndex);
				if(value != 0x00) {
					//Printf(" REG%01bx%02bx W:00 R:%02bx", page,Index,value);
					Printf(" W:00_R:%02bx", value);
				}
				WriteTW88(PageIndex, 0xFF & pWMask[Index]);
				value = ReadTW88(PageIndex);
				if((value & pWMask[Index]) != (0xFF & pWMask[Index])) {
					//Printf(" REG%01bx%02bx W:%02bx R:%02bx", page,Index, pWMask[Index], value);
					Printf(" W:%02bx_R:%02bx", pWMask[Index], value);
				}
				WriteTW88(PageIndex,prev_data);
			}
		}
	} 
}