Exemple #1
0
void sleep_tick() {
	if (ux_state())
		timenobtn = 0;
	timenobtn++;
	if (timenobtn > 20 * 10000)
		deepPowerDown();
}
Exemple #2
0
int main() {
	/*
	IOCON_PIO1_5 = 0x000000d0;
	GPIO1DIR |= 1 << 5;
	GPIO1MASKED[1 << 5] = 0;
	for (int i = 0;; i++) {
		GPIO1MASKED[1 << 5] = i;
	}
	*/
	matrixled_init();
	ux_init();
	
#if ENEBLE_WDT == 1
	slowClock();
#endif
	
#if SYSTICK_WAIT == 1
#if ENEBLE_WDT == 1
	InitSysTick(120000);
#else
	InitSysTick(12000);	// 12,000,000Hz 12,000 -> 10 = 1ms
#endif
#endif
	
#if ENEBLE_WDT == 0
	initUART();
#endif
	
	/*
	for (;;) {
		playMML("C");
		println("TEST\n");
		toggleSounder();
		wait(10000);
	}
//	uart();
	*/
	
//	bitman();
	//	bitman2();
	for (;;) {
		if (!ux_state()) {
			break;
		}
		WAIT(10);
	}
	for (;;) {
		animate(DATA_ANIM, LEN_DATA_ANIM);
		app_mikuji();
//		app_keytest();
		app_renda();
	}
	return 0;
}
Exemple #3
0
void ux_tick() {
	if (btncount > 0) {
		btncount--;
		return;
	}
	int btn = ux_state();
	if (btn && !bkuxbtn) {
		uxbtn = 1;
		uxbtnret = 1;
		btncount = BTN_RESET;
	}
	bkuxbtn = btn;
}
Exemple #4
0
void app_keytest() {
	for (;;) {
		CLS(ux_state());
		FLUSH();
//		WAIT(10);
	}
	int flg = 0;
	for (;;) {
		if (ux_btn())
			flg = !flg;
		CLS(flg);
		FLUSH();
//		WAIT(1000); // 1,000sec
		WAIT(1000);
	}
}
Exemple #5
0
void app_mikuji() { // おみくじ
	for (;;) {
		playMML("C8G8C8>G4");
		ux_btn();
		for (;;) {
			FILL("c152f4d2014a4530"); // title
			FLUSH();
			if (ux_btn())
				break;
			rnd();
		}
		systick = 0;
		for (;;) {
			WAIT(10);
			if (!ux_state())
				break;
			if (systick > 10000)
				return;
		}
		
		// 00494bef4da9af00 大凶
		int btn = 0;
		systick = 0;
		// 大中小末
		char* PTN_UP[] = {
					"00494bef4da9af00", // 大
					"0049ebefed494f00", // 中
					"00464f46ef594f00", // 小
					"00e64fe64fe9df00", // 末
				};
		char* PTN_DOWN[] = {
					"0060f060f090f000", // 吉
					"0090b0f0d090f000", // 凶
				};
		playMML("G8");
		for (int k = 0; k < 8; k++) {
			CLS(0);
			matrix_put("c152f4d2014a4530", 0, -k, 8, 8);
			matrix_put("00494bef4da9af00", 0, -k + 8, 8, 8);
			FLUSH();
			WAIT(2000 - k * 20);
		}
		int view = 0;
		int next = rnd() % 4;
		int view2 = 0;
		int next2 = rnd() % 2;
		int state = 0;
		int wcnt = 15;
		int wcnt2 = 15;
		int i = 0;
		int j = 0;
		int ccnt = 0;
		int ccnt2 = 0;
		ux_btn();
		for (;;) {
			CLS(0);
			matrix_put(PTN_UP[view], 0, -(i % 8), 4, 8); // 大
			matrix_put(PTN_UP[next], 0, 8 - i % 8, 4, 8); // 中
			matrix_put(PTN_DOWN[view2], 4, -(j % 8), 4, 8); // 吉
			matrix_put(PTN_DOWN[next2], 4, 8 - j % 8, 4, 8); // 吉
			FLUSH();
			WAIT(1);
			if (!btn) {
//				if (systick > 10000 && ux_btn())
				//					btn = 1;
				if (ux_btn()) {
					playMML("A8");
					btn = 1;
				}
			}
			if (state == 0) {
				ccnt++;
				if (ccnt == wcnt) {
					i++;
					ccnt = 0;
					if (i % 8 == 0) {
						playMML("C16");
						view = next;
						int n = rnd() % 6;
						next = n > 3 ? 0 : n;
						if (btn) {
							wcnt += wcnt;
							if (wcnt > 100) {
								state++;
								btn = 0;
							}
						}
					}
				}
			}
			ccnt2++;
			if (ccnt2 == wcnt2) {
				j++;
				ccnt2 = 0;
				if (j % 8 == 0) {
					if (state == 1)
						playMML("C16");
					view2 = next2;
					next2 = rnd() % 4 == 0 ? 1 : 0;
					if (state == 1) {
						if (btn) {
							wcnt2 += wcnt2;
							if (wcnt2 > 100)
								break;
						}
					}
				}
			}
		}
		if (view == 0 && view2 == 0) {
			playMML("G16R8G2");
		} else if (view2 == 1) {
			playMML("C2C8C8");
		} else {
			playMML("C8E8G8");
		}
		ux_btn();
		for (;;) {
			matrix_put(PTN_UP[view], 0, -(i % 8), 4, 8); // 大
			matrix_put(PTN_DOWN[view2], 4, 0, 4, 8); // 吉
			FLUSH();
			WAIT(10);
			if (ux_btn())
				break;
		}
		/*
		for (;;) {
			WAIT(100);
			if (!ux_btn())
				break;
		}
		*/
	}
}
Exemple #6
0
void app_renda() { // 連打ゲーム
	for (;;) {
		playMML("L8EGG");
		ux_btn();
		for (;;) {
			FILL("8aa2cc006595f010"); // title
//			FILL("8aa2cc006a953060"); // title
			FLUSH();
			if (ux_btn())
				break;
		}
		systick = 0;
		for (;;) {
			WAIT(10);
			if (!ux_state())
				break;
			if (systick > 10000) 
				return;
		}
		playMML("C");
		FILL(PTN_3);
		FLUSH();
		WAIT(1000);
		playMML("C");
		FILL(PTN_2);
		FLUSH();
		WAIT(1000);
		playMML("C");
		FILL(PTN_1);
		FLUSH();
		WAIT(1000);
		playMML("G2");
		FILL(PTN_GO);
		FLUSH();
		WAIT(1000);
		
		CLS(1);
		FLUSH();
		systick = 0;
		int cnt = 0;
		int bkbtn = 0;
		ux_btn();
		for (;;) {
			int btn = ux_btn();
			if (btn) {
				playMML("A16");
				PRESET(cnt % 8, cnt / 8);
				FLUSH();
				cnt++;
				if (cnt == 64)
					break;
			}
//			bkbtn = btn;
		}
		playMML("L8CEG");
		FILL("00c9aaacacaaaa69"); // ok
		xprintf("%d\n", systick);
		unsigned int score = 100000 / (systick / 64);
		xprintf("%d\n", score);
		/*
		for (int i = 0;; i++) {
			int n = time % 10;
			time /= 10;
			if (time == 0)
				break;
			FILL(PTN_NUM[n]);
			FLUSH();
			WAIT(500);
		}
		*/
		if (score > 250)
			score = 250;
		FILL(PTN_NUM[score / 10]);
		PSET(6, 6);
		FLUSH();
		WAIT(1000);
		FILL(PTN_NUM[score % 10]);
		FLUSH();
		WAIT(1000);
		FLUSH();
		WAIT(1000);
	}
}
Exemple #7
0
void app_bitman() {
	char data[16];
	decode_left2right("0098e41f1fe49800", data);
	decode_left2right("0884e43e3ee48408", data + 8);

	const struct Frame fr[BITMAN_MAX_PTN] = {
		  { { 0x08, 0x84, 0xE4, 0x1E, 0x1E, 0xE4, 0x84, 0x08 }, 400 }
		, { { 0x00, 0x98, 0xE4, 0x1F, 0x1F, 0xE4, 0x98, 0x00 }, 600 }
		, { { 0x08, 0x84, 0xE4, 0x1E, 0x1E, 0xE4, 0x84, 0x08 }, 600 }
		, { { 0x00, 0x98, 0xE4, 0x1F, 0x1F, 0xE4, 0x98, 0x00 }, 600 }
		, { { 0x00, 0x84, 0xE4, 0x14, 0x1E, 0xEE, 0x84, 0x08 }, 400 }
		, { { 0x00, 0x42, 0x72, 0x14, 0x1E, 0xFE, 0x84, 0x18 }, 200 }
		, { { 0x06, 0x04, 0x04, 0x09, 0x1E, 0xEC, 0x8E, 0x36 }, 200 }
		, { { 0x06, 0x64, 0x24, 0x3D, 0x0D, 0x7E, 0x0C, 0x0C }, 200 }

		, { { 0x66, 0x24, 0x24, 0x18, 0x99, 0x7E, 0x18, 0x00 }, 400 }
		, { { 0x66, 0x24, 0x24, 0x5A, 0x5A, 0x3C, 0x18, 0x18 }, 600 }
		, { { 0x66, 0x24, 0x24, 0x18, 0x99, 0x7E, 0x18, 0x00 }, 600 }
		, { { 0x66, 0x24, 0x24, 0x5A, 0x5A, 0x3C, 0x18, 0x18 }, 600 }
		, { { 0x66, 0x24, 0x24, 0x18, 0xB0, 0x7E, 0x30, 0x00 }, 400 }
		, { { 0x60, 0x26, 0x24, 0xBC, 0xB0, 0x78, 0x36, 0x00 }, 200 }
		, { { 0x60, 0x20, 0xA0, 0x90, 0x78, 0xF7, 0xD1, 0x08 }, 200 }
		, { { 0x00, 0x22, 0x2E, 0x28, 0xF8, 0xFF, 0x21, 0x18 }, 200 }

		, { { 0x10, 0x21, 0x27, 0x78, 0x78, 0x27, 0x21, 0x10 }, 400 }
		, { { 0x00, 0x19, 0x27, 0xF8, 0xF8, 0x27, 0x19, 0x00 }, 600 }
		, { { 0x10, 0x21, 0x27, 0x78, 0x78, 0x27, 0x21, 0x10 }, 600 }
		, { { 0x00, 0x19, 0x27, 0xF8, 0xF8, 0x27, 0x19, 0x00 }, 600 }
		, { { 0x10, 0x21, 0x77, 0x78, 0x28, 0x27, 0x21, 0x00 }, 400 }
		, { { 0x18, 0x21, 0x7F, 0x78, 0x28, 0x4E, 0x42, 0x00 }, 200 }
		, { { 0x6C, 0x71, 0x37, 0x78, 0x90, 0x20, 0x20, 0x60 }, 200 }
		, { { 0x30, 0x30, 0x7E, 0xB0, 0xBC, 0x24, 0x26, 0x60 }, 200 }

		, { { 0x00, 0x18, 0x7E, 0x99, 0x18, 0x24, 0x24, 0x66 }, 400 }
		, { { 0x18, 0x18, 0x3C, 0x5A, 0x5A, 0x24, 0x24, 0x66 }, 600 }
		, { { 0x00, 0x18, 0x7E, 0x99, 0x18, 0x24, 0x24, 0x66 }, 600 }
		, { { 0x18, 0x18, 0x3C, 0x5A, 0x5A, 0x24, 0x24, 0x66 }, 600 }
		, { { 0x00, 0x0C, 0x7E, 0x0D, 0x18, 0x24, 0x24, 0x66 }, 400 }
		, { { 0x00, 0x6C, 0x1E, 0x0D, 0x3D, 0x24, 0x64, 0x06 }, 200 }
		, { { 0x10, 0x8B, 0xEF, 0x1E, 0x09, 0x05, 0x04, 0x06 }, 200 }
		, { { 0x18, 0x84, 0xFF, 0x1F, 0x14, 0x74, 0x44, 0x00 }, 200 }
	};

//	int ptn = 0;
	int exit_triger = 0;
	int exit_count = 0;
	int	nframe = 0;		// 実行中のフレーム番号
	int	cnt = 0;		// RUN時のwaitカウンタ

	set_matrix(data);
	playMML("CDE2CDE2");

	// Bitman_Title added by 後田浩さん Thanks !
	for (;;) {
		FILL("191A3C5898242466"); // title
		FLUSH();
		if (ux_btn()) break;
	}
	set_systick(0);
	for (;;) {
		WAIT(10);
		if (!ux_state()) break;
		if (get_systick() > 10000) return;
	}
	// end_of_Bitman_Title

	playMML("C16");
	set_systick(0);
	set_matrix(fr[nframe].frame);
	for (;;) {
		WAIT(1);
		cnt++;
		if (cnt >= fr[nframe].waitms) { // 待ち時間を過ぎたら
			cnt = 0;
			playMML("<C16");

			// 次に接続されているマトリクスに送るデータ
			xprintf("MATLED SHOW ");
			for (int j = 0 ; j < 8 ; j++) xprintf("%02X", fr[nframe].frame[j]);
			xprintf("\n");

			// 次のフレームに切り替え
			nframe++;
			if (nframe == BITMAN_MAX_PTN || fr[nframe].waitms == 0) nframe = 0;	// ループして最初から
			set_matrix(fr[nframe].frame);
		}

		if (ux_state()) {	// ボタンが押されていたら
			if (exit_count == 1) return;
			if (exit_triger == get_systick()) exit_count++;
			if (exit_triger == 0) {
				playMML("C16");
				exit_triger = get_systick();
				no_sleep();
			}
		}
		if (!ux_state()) {	// ボタンが離されていたら
			exit_triger = 0;
		}
		if (get_systick() > 10000) set_systick(0);
	}
}