Ejemplo n.º 1
0
int main(int argc, char *argv[]) {
	FILE *fp;
	bool ctrl = false, insr = false, move = false;
	char curr, scrn[10][10];
	int x = 0, y = 0, i, j;
	cls(scrn);

	if (argc != 2) {
		printf("Usage: %s [FILE]\n", argv[0]);
		return 1;
	}
	fp = fopen(*++argv, "r");
	while (fscanf(fp, "%c", &curr) != EOF) {
		if (curr == '\n')
			continue;
		if (ctrl) {
			switch (curr) {
			case '^':
				y = prn(scrn, x, y, curr, insr);
				ctrl = false;
				break;
			case 'c':
				cls(scrn);
				ctrl = false;
				break;
			case 'e':
				for (i = 8; i >= y; i--)
					scrn[x][i] = ' ';
				ctrl = false;
				break;
			case 'i':
				insr = true;
				ctrl = false;
				break;
			case 'o':
				insr = false;
				ctrl = false;
				break;
			case 'h':
				x = 0;
			case 'b':
				y = 0;
				ctrl = false;
				break;
			case 'd':
				if (x < 9)
					x++;
				ctrl = false;
				break;
			case 'u':
				if (x > 0)
					x--;
				ctrl = false;
				break;
			case 'l':
				if (y > 0)
					y--;
				ctrl = false;
				break;
			case 'r':
				if (y < 9)
					y++;
				ctrl = false;
				break;
			default:
				if (curr < '0' || curr > '9')
					break;
				if (!move) {
					move = true;
					x = curr - '0';
				} else {
					move = false;
					y = curr - '0';
					ctrl = false;
				}
			}
		} else {
			switch (curr) {
			case '^':
				ctrl = true;
				break;
			default:
				y = prn(scrn, x, y, curr, insr);
			}
		}
	}

	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++)
			putchar(scrn[i][j]);
		putchar('\n');
	}
	return 0;
}
Ejemplo n.º 2
0
uint8 read_card_loop()
{	
	uint8 ret;
	bit flag1;
	uint16 tick;
	cls();
	Display(0,0,g_z18pos.welcome_msg,0);
	tick = 0;
	g_lcd_flag = 0;
	flag1 = 0;
	if(z18pos_check_coll_interval())
		return KNG_POS_EXPIRED_COLL;
	Led_OnOff(1,0);
	while(1)
	{
		clr_dog();
		ret = GetKeyVal(1);
		if(ret != 0xFF)
			Lcd_onoff(1);
		if(ret == KEY_ESC)
			break;
		ret = mif_request(0);
		if(flag1)
		{
			cls();
			Display(0,0,g_z18pos.welcome_msg,0);
			flag1 = 0;
		}

		if(ret == Z18_FAILED)
		{
            z18pos_check_consume();
            kng_sleep(1);
			tick+=3;
			if(tick >= 60)
			{
				tick = 0;
				cls();
				Display(0,0,g_z18pos.welcome_msg,0);
				//Led_OnOff(1,1);
				Lcd_onoff(0);
				g_lcd_flag = 0;
                InitRtcTime();
	            ReadRtcTime(g_z18pos.curr_time);
			}
			if(z18pos_check_coll_interval())
			{
				KNG_AUDIO(AU_NEED_COL,Z18_AUDIO_DELAY);
				print_error(KNG_POS_EXPIRED_COLL,NULL);
				return KNG_POS_EXPIRED_COLL;
			}
		}
		else
		{
            InitRtcTime();
	        ReadRtcTime(g_z18pos.curr_time);
			memset(&g_mycard,0,sizeof g_mycard);
			g_mycard.last_login_sect = 0xFF;
			tick = 0;
			// 寻卡成功
			ret = consume_card();
			if(ret>0)
			{
				debug_string("consume [%d]\n",(uint16)ret);
			}
			switch(ret)
			{
			case KNG_POS_PARAM_ERROR:
				print_error(ret,"请联系管理员");
				break;
			case KNG_POS_HARDWARE_ERROR:
				print_error(ret,"请检查POS机");
				break;
			case KNG_POS_NO_RIGHT:
				print_error(ret,NULL);
				break;
			case  KNG_POS_NOT_SUPP_CARDTYPE:
				print_error(ret,NULL);
				break;
			case KNG_POS_SUCCESS:
				break;
			case KNG_POS_UNEXPECT_CARD:
				break;
            case KNG_POS_REC_FULL:
                KNG_AUDIO(AU_NEED_COL,Z18_AUDIO_DELAY);
                print_error(ret,"请采集");
                break;
			default:
				break;
			}
			flag1 = 1;
		}
	}
	return 0;
}
Ejemplo n.º 3
0
Archivo: cOS.c Proyecto: jiangeZh/myOS
cDo()
{
	printf(str3,0x0b14,41);
	while (buffer1 < 9)
	{	
		getch(&order[buffer1]);
		if (order[buffer1] == '1' || order[buffer1] == '2' || order[buffer1] == '3' || order[buffer1] == '4'|| order[buffer1] == '5'|| order[buffer1] == '6'|| order[buffer1] == '7'|| order[buffer1] == '8' || order[buffer1] == '9')
		{
			putch(order[buffer1]);
			buffer1++;	
		}
		else if (order[buffer1] == '\r') break;
	}

	for (; j < buffer1; j++)
	{
		if (order[j] == '1')
		{
			cls();
			load(0x1000,1,12);
			do1();
		}
		
		else if (order[j] == '2')
		{
			cls();
			load(0x2000,1,13);
			do2();
		}
		else if (order[j] == '3')
		{
			cls();
			load(0x3000,1,14);
			do3();
		}
		else if (order[j] == '4')
		{
			cls();
			load(0x4000,1,15);
			do4();
		}
		else if (order[j] == '5')
		{
			cls();
			load(0x5000,1,16);
			do5();
		}
		else if (order[j] == '6')
		{
			cls();
			load(0x6000,2,17);
			do6();
		}
		else if (order[j] == '7')
		{
			cls();
			load(0x7000,1,19);
			do7();
		}
		else if (order[j] == '8')
		{
			cls();
			load(0x8000,1,20);
			do8();
		}
		else if (order[j] == '9')
		{
			cls();
			freeAll();
			Program_Num = 1;
			CurrentPCBno = 1;
			load(0x9000,2,21);
			init(&pcb_list[0],0,0x7e00);
			init(&pcb_list[1],0x9000,0x100);
			setClock();
			do9();
			Program_Num = 0;
		}
	}
	cls();
	printf(str4,0x0a20,17);
	printf("Press any key to return...",0x0c15,26);
	buffer1 = 0;
	getch(&ret);
	return;
}
Ejemplo n.º 4
0
Object c_Closure::t_bindto(const Variant& newthis, const Variant& scope) {
  if (RuntimeOption::RepoAuthoritative &&
      RuntimeOption::EvalAllowScopeBinding) {
    raise_warning("Closure binding is not supported in RepoAuthoritative mode");
    return nullptr;
  }

  auto const cls = getVMClass();
  auto const invoke = cls->getCachedInvoke();

  ObjectData* od = nullptr;
  if (newthis.isObject()) {
    if (invoke->isStatic()) {
      raise_warning("Cannot bind an instance to a static closure");
    } else {
      od = newthis.getObjectData();
    }
  } else if (!newthis.isNull()) {
    raise_warning("Closure::bindto() expects parameter 1 to be object");
    return nullptr;
  }

  auto const curscope = invoke->cls();
  auto newscope = curscope;

  if (scope.isObject()) {
    newscope = scope.getObjectData()->getVMClass();
  } else if (scope.isString()) {
    auto const className = scope.getStringData();

    if (!className->equal(s_static.get())) {
      newscope = Unit::loadClass(className);
      if (!newscope) {
        raise_warning("Class '%s' not found", className->data());
        return nullptr;
      }
    }
  } else if (scope.isNull()) {
    newscope = nullptr;
  } else {
    raise_warning("Closure::bindto() expects parameter 2 "
                  "to be string or object");
    return nullptr;
  }

  if (od && !newscope) {
    // Bound closures should be scoped.  If no scope is specified, scope it to
    // the Closure class.
    newscope = static_cast<Class*>(c_Closure::classof());
  }

  bool thisNotOfCtx = od && !od->getVMClass()->classof(newscope);

  if (!RuntimeOption::EvalAllowScopeBinding) {
    if (newscope != curscope) {
      raise_warning("Re-binding closure scopes is disabled");
      return nullptr;
    }

    if (thisNotOfCtx) {
      raise_warning("Binding to objects not subclassed from closure "
                    "context is disabled");
      return nullptr;
    }
  }

  c_Closure* clone = Clone(this);
  clone->setClass(nullptr);

  Attr curattrs = invoke->attrs();
  Attr newattrs = static_cast<Attr>(curattrs & ~AttrHasForeignThis);

  if (od) {
    od->incRefCount();
    clone->setThis(od);

    if (thisNotOfCtx) {
      // If the bound $this is not a subclass of the context class, then we
      // have to pessimize translation.
      newattrs |= AttrHasForeignThis;
    }
  } else if (newscope) {
    // If we attach a scope to a function with no bound $this we need to make
    // the function static.
    newattrs |= AttrStatic;
    clone->setClass(newscope);
  }

  // If we are changing either the scope or the attributes of the closure, we
  // need to re-scope its Closure subclass.
  if (newscope != curscope || newattrs != curattrs) {
    assert(newattrs != AttrNone);

    auto newcls = cls->rescope(newscope, newattrs);
    clone->setVMClass(newcls);
  }

  return Object(clone);
}
Ejemplo n.º 5
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /* Initializes a serial-over-USB CDC driver.*/
  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);

  /*
   * Activates the USB driver and then the USB bus pull-up on D+.
   * Note, a delay is inserted in order to not have to disconnect the cable
   * after a reset.
   */
  usbDisconnectBus(serusbcfg.usbp);
  chThdSleepMilliseconds(1500);
  usbStart(serusbcfg.usbp, &usbcfg);
  usbConnectBus(serusbcfg.usbp);

  /* Creates the blinker thread.*/
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL);

  /* LSM303DLHC Object Initialization.*/
  lsm303dlhcObjectInit(&LSM303DLHCD1);

  /* Activates the LSM303DLHC driver.*/
  lsm303dlhcStart(&LSM303DLHCD1, &lsm303dlhccfg);

  /* Normal main() thread activity, printing MEMS data on the SDU1.*/
  while (true) {
    lsm303dlhcAccelerometerReadRaw(&LSM303DLHCD1, accraw);
    chprintf(chp, "LSM303DLHC Accelerometer raw data...\r\n");
    for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++) {
      chprintf(chp, "%c-axis: %d\r\n", axisID[i], accraw[i]);
    }

    lsm303dlhcCompassReadRaw(&LSM303DLHCD1, compraw);
    chprintf(chp, "LSM303DLHC Compass raw data...\r\n");
    for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++) {
      chprintf(chp, "%c-axis: %d\r\n", axisID[i], compraw[i]);
    }

    lsm303dlhcAccelerometerReadCooked(&LSM303DLHCD1, acccooked);
    chprintf(chp, "LSM303DLHC Accelerometer cooked data...\r\n");
    for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++) {
      chprintf(chp, "%c-axis: %.3f\r\n", axisID[i], acccooked[i]);
    }

    lsm303dlhcCompassReadCooked(&LSM303DLHCD1, compcooked);
    chprintf(chp, "LSM303DLHC Compass cooked data...\r\n");
    for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++) {
      chprintf(chp, "%c-axis: %.3f\r\n", axisID[i], compcooked[i]);
    }
    chThdSleepMilliseconds(100);
    cls(chp);
  }
  lsm303dlhcStop(&LSM303DLHCD1);
}
Ejemplo n.º 6
0
void showSplashScreen()
{
    hideCursor();
	cls();
	set_bkg_tiles(6,7,8,2,logo);
}
Ejemplo n.º 7
0
void showSampleScreen()
{
	hideCursor();
	cls();
	currentScreen = 1;
}
Ejemplo n.º 8
0
		void init() {
			cls(h,-1);
			e=0;
		}
Ejemplo n.º 9
0
static const TCHAR *
detect_language()
{
#ifdef ANDROID

  JNIEnv *env = Java::GetEnv();

  Java::Class cls(env, "java/util/Locale");

  // Call static function Locale.getDefault() that
  // returns the user's default Locale object

  jmethodID cid = env->GetStaticMethodID(cls, "getDefault",
                                         "()Ljava/util/Locale;");
  assert(cid != NULL);

  jobject _obj = env->CallStaticObjectMethod(cls, cid);
  if (_obj == NULL)
    return NULL;

  Java::LocalObject obj(env, _obj);

  // Call function Locale.getLanguage() that
  // returns a two-letter language string

  cid = env->GetMethodID(cls, "getLanguage", "()Ljava/lang/String;");
  assert(cid != NULL);

  jstring language = (jstring)env->CallObjectMethod(obj, cid);
  if (language == NULL)
    return NULL;

  // Convert the jstring to a char string
  const char *language2 = env->GetStringUTFChars(language, NULL);
  if (language2 == NULL) {
    env->DeleteLocalRef(language);
    return NULL;
  }

  /* generate the resource name */

  const char *language3 = language2;
  if (strcmp(language3, "pt") == 0)
    /* hack */
    language3 = "pt_BR";

  // Attach .mo to the language identifier
  static char language_buffer[16];
  snprintf(language_buffer, sizeof(language_buffer), "%s.mo", language3);

  // Clean up the memory
  env->ReleaseStringUTFChars(language, language2);
  env->DeleteLocalRef(language);

  // Return e.g. "de.mo"
  return language_buffer;

#else /* !ANDROID */

#if defined(_WIN32_WCE)
  /* the GetUserDefaultUILanguage() prototype is missing on
     mingw32ce, we have to look it up dynamically */
  DynamicLibrary coreloc_dll(_T("coredll"));
  if (!coreloc_dll.IsDefined()) {
    LogStartUp(_T("Language: coredll.dll not found"));
    return NULL;
  }

  typedef LANGID WINAPI (*GetUserDefaultUILanguage_t)();
  GetUserDefaultUILanguage_t GetUserDefaultUILanguage =
    (GetUserDefaultUILanguage_t)
    coreloc_dll.Lookup(_T("GetUserDefaultUILanguage"));
  if (GetUserDefaultUILanguage == NULL) {
    LogStartUp(_T("Language: GetUserDefaultUILanguage() not available"));
    return NULL;
  }
#endif

  // Retrieve the default user language identifier from the OS
  LANGID lang_id = GetUserDefaultUILanguage();
  LogStartUp(_T("Language: GetUserDefaultUILanguage()=0x%x"), (int)lang_id);
  if (lang_id == 0)
    return NULL;

  // Try to convert the primary language part of the language identifier
  // to a MO file name in the language table
  return find_language(PRIMARYLANGID(lang_id));

#endif /* !ANDROID */
}
Ejemplo n.º 10
0
void main() {

	#define PALSIZE 8
	char *palette=" -=*O@@@@_";
	
	srand(time(NULL));
	// Needed
	initscr(); cbreak(); noecho();
	// Optional
	nonl(); intrflush(stdscr,FALSE); keypad(stdscr,FALSE);
	printf("%i x %i\n",COLS,LINES);

	if (has_colors()) {
		start_color();
		init_pair(0,COLOR_BLACK,COLOR_BLACK);
		init_pair(1,COLOR_BLUE,COLOR_BLACK);
		init_pair(2,COLOR_RED,COLOR_BLACK);
		init_pair(3,COLOR_MAGENTA,COLOR_BLACK);
		init_pair(4,COLOR_GREEN,COLOR_BLACK);
		init_pair(5,COLOR_CYAN,COLOR_BLACK);
		init_pair(6,COLOR_YELLOW,COLOR_BLACK);
		init_pair(7,COLOR_WHITE,COLOR_BLACK);
	}

	frames=0;

	cls();

	while (true) {
		
		// doSummat(&lonewriteToPoint);

		cenx = COLS / 2;
		ceny = LINES / 2;
		swirlang = (float)frames * M_PI / 800.0;
		// Zooming in and out over time
		spacePerSwirl = 0.08+0.03*cos(0.000638*(float)frames);

		move(0,0);
		attrset(COLOR_PAIR(2) | A_BOLD);

		for (int y = 0;y<LINES;y++) {
			for (int x = 0;x<COLS;x++) {

				float swirlHeight=getSwirlHeight(x,y);
				{
					int c=
							( getSwirlHeight(x+1,y+1) > 0 ? 1 : 0 )
						+	( getSwirlHeight(x,y+1) > 0 ? 1 : 0 )
						+	( getSwirlHeight(x+1,y) > 0 ? 1 : 0 )
						+	( getSwirlHeight(x,y) > 0 ? 1 : 0 )
						+	( getSwirlHeight((float)x+0.5,(float)y+0.5) > 0 ? 1 : 0 );
					char ch = palette[c];
					// mvaddch(y,x,32);
					addch(ch);
				}

			}
		}

		// int x = frames%COLS;
		// int y = (frames/COLS)%LINES;
		// move(y,x);
		// attrset(COLOR_PAIR(7));
		// char *str;
		// sprintf(str," (- %i -) ",frames);
		// addstr(str);
		// printf("%i ",frames);
		// move(1,0);
		// attrset(COLOR_PAIR(0));
		// printf("%i ",frames);
		wrefresh(stdscr);

		frames += 10;

	}

	cls();

	// Needed
	endwin();
}