PWM
This commit is contained in:
parent
0b260c78ab
commit
16cda07a7e
|
@ -7,24 +7,10 @@
|
|||
#include <keyboard.h>
|
||||
#include <mpu.h>
|
||||
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
//#define PI 3.141592653584
|
||||
/*
|
||||
void switchStatePin()
|
||||
{
|
||||
if(isSH3())
|
||||
{
|
||||
*(volatile unsigned char*)SH7337_SCPDR ^= 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(volatile unsigned char*)SH7305_PJDR ^= 0x04;
|
||||
}
|
||||
}*/
|
||||
|
||||
const char* bincod = "111011001000100011101" ;
|
||||
char bincod[12] = {0};
|
||||
char place = 0;
|
||||
|
||||
unsigned char range = 0;
|
||||
|
||||
|
@ -32,7 +18,7 @@ void lect()
|
|||
{
|
||||
// range = (range < 20 ? range +1 : 0);
|
||||
|
||||
if(bincod[range] != bincod[range+1])
|
||||
if(bincod[range%place] != bincod[(range+1)%place])
|
||||
{
|
||||
if(isSH3())
|
||||
{
|
||||
|
@ -43,7 +29,7 @@ void lect()
|
|||
*(volatile unsigned char*)SH7305_PJDR ^= 0x04;
|
||||
}
|
||||
}
|
||||
range = (range < 19 ? range +1 : 0);
|
||||
range++;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,7 +38,7 @@ int main(void)
|
|||
{
|
||||
unsigned int key=0;
|
||||
|
||||
int freq = 1;
|
||||
int freq = 440;
|
||||
|
||||
//unsigned int i=0;
|
||||
|
||||
|
@ -62,14 +48,9 @@ int main(void)
|
|||
{
|
||||
dclear();
|
||||
|
||||
// dprint(1, 1, "%d", freq);
|
||||
// PrintMini(1, 1, itoa(freq, str, 10), 0);
|
||||
// dprint(1, 10, "%d", !isSH3());
|
||||
dprint(1, 1, "%d", freq);
|
||||
dprint(1, 10, "%s , %d", bincod, place);
|
||||
|
||||
//dprint(1,20, "%c , %c", bincod[range], bincod[range+1]);
|
||||
// dprint(1, 20, "%d", range);
|
||||
|
||||
//PrintMini(1, 10, itoa(is_SH4, str, 10), 0);
|
||||
dupdate();
|
||||
|
||||
key=getkey();
|
||||
|
@ -81,14 +62,19 @@ int main(void)
|
|||
case KEY_UP : freq+=10; break;
|
||||
case KEY_DOWN : freq-=10; break;
|
||||
|
||||
case KEY_F1 : *(bincod+place) = '_'; place++; range = 0; break;
|
||||
case KEY_F2 : *(bincod+place) = '-'; place++; range = 0;break;
|
||||
case KEY_DEL : place=(place>0 ? place - 1 : 0); *(bincod+place) = 0; range = 0; break;
|
||||
|
||||
case KEY_EXE :
|
||||
timer_start(TIMER_USER, 8800, Clock_Hz, lect, 0);
|
||||
timer_start(TIMER_USER, freq*place, Clock_Hz, lect, 2*freq*place);
|
||||
|
||||
break;
|
||||
case KEY_EXIT :
|
||||
timer_stop(TIMER_USER);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
return 1; // this point is never reached
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue