[LCD] Kick the initial word, this is bad-knowhow, but needed from SC1602BBWB-XA-LB-G, akizukidenshi's LCD display :(
b = _LCDPORT_CONT_LATCH;
b &= ~(_LCDPORT_CONT_RW | 0xf0 | _LCDPORT_CONT_EN); // DATA=blank,RW='0'
b |= _LCDPORT_CONT_RS; // RS='1"
- b |= h;
_LCDPORT_CONT_LATCH = b;
_ACM1602_TC_WAIT(); // Wait 2.5?us
b |= _LCDPORT_CONT_EN; // Do high write.
+ b |= h;
_LCDPORT_CONT_LATCH = b;
_ACM1602_TC_WAIT(); // Wait 2.5?us
b = _LCDPORT_CONT_LATCH;
b &= 0x0f; // DATA=blank,RW='0'
b |= _LCDPORT_CONT_RS; // RS='1"
- b |= l;
_LCDPORT_CONT_LATCH = b;
_ACM1602_TC_WAIT(); // Wait 2.5?us
b |= _LCDPORT_CONT_EN;
+ b |= l;
_LCDPORT_CONT_LATCH = b; // Do low write.
_ACM1602_TC_WAIT(); // Wait 2.5?us
b &= ~_LCDPORT_CONT_EN; // Disable EN
_LCDPORT_CONT_LATCH = b;
- _ACM1602_TC_WAIT(); // Wait 2.5?us
+ _ACM1602_SHORT_WAIT();
#else
_ACM1602_SHORT_WAIT();
// Send twice on 4Bit Mode.
// sendonce(addr, 0x30); // 2lines, 8x10dot fonts.
- sendcmd(addr, 0x28, 0x00); // 2lines, 8x5dot fonts.
+ sendcmd(addr, 0x28, 0xff); // 2lines, 8x5dot fonts.
#endif
#endif
// sendcmd(addr, 0x08, 0xff); // Display OFF.
unsigned char input_flag;
unsigned char c;
unsigned int i;
+ unsigned char pa,pb,pc,pd;
#ifdef _LCD_DEBUG
unsigned char power_flag;
#endif
- OSCCON = (_IDLEN & 0b11111100) | 0b00111000;
+// OSCCON = (_IDLEN & 0b11111100) | 0b00111000;
keyin_init();
keyin_ioinit();
backlight_long = 256;
backlight_counter = backlight_long;
backlight_level = 255;
- ui_idlecount = 0xf800;
+ ui_idlecount = 65535 - 7182/4 + 1; // 0.25Sec
acm1602_init(0xa0, 1); //Init LCD
_AKC6955_WAIT_125_0MS(); // Wait 125ms
- // _LOCATE(0,0);
- // _PUTCHAR('c');
- _LOCATE(0,0);
+ _LOCATE(0,0); // It's BAD-KNOWHOW, but needs AKIZUKI'S LCD :(
+ _PUTCHAR(' '); //
+ _LOCATE(0,1);
printstr("Hello;-)");
acm1602_setbacklight(0xff);
// PORTD |= _LCDPORT_CONT_RS;
#if 1
i = 10001;
do {
- idle(65535-7812);
- ClrWdt();
+ PORTA = 0xff;
+ idle(65535-256);
+ PORTA = 0xfe;
+ idle(65535-256);
+ pa = PORTB;
+
+ PORTA = 0xff;
+ idle(65535-256);
+ PORTA = 0xfd;
+ idle(65535-256);
+ pb = PORTB;
+
+ PORTA = 0xff;
+ idle(65535-256);
+ PORTA = 0xfb;
+ idle(65535-256);
+ pc = PORTB;
+
+ PORTA = 0xff;
+ idle(65535-256);
+ PORTA = 0xf7;
+ idle(65535-256);
+ pd = PORTB;
+ _LOCATE(0,0);
+ print_numeric_nosupress(pa, 3);
+ _PUTCHAR(' ');
+ print_numeric_nosupress(pb, 3);
_LOCATE(0,1);
- print_numeric_nosupress(i, 5);
+ print_numeric_nosupress(pc, 3);
+ _PUTCHAR(' ');
+ print_numeric_nosupress(pd, 3);
+ ClrWdt();
+ idle(65535-7128/10 + 1);
// print_numeric(i, 1);
// PORTDbits.RD3 = i & 1;
- i = i + 1;
+// i = i + 1;
}while(1);
#else
+// idle(0xffff);
switch(load_eeprom()) {
case 0x01: // No magic-word
- idle(0xff80);
+ idle(65535-7128*2+1);
_CLS();
setdefault();
_LOCATE(0,0);
printstr("Press any key");
do {
input_flag = readkey_compare();
- idle(0xff80);
+ idle(ui_idlecount);
+ ClrWdt();
} while(input_flag == 0);
+ _CLS();
+ _LOCATE(0,0);
+ printstr("Formatting...");
c = pop_keyinfifo();
format_eeprom(0,254);
save_eeprom();
input_flag = readkey_compare();
idle(0xff80);
} while(input_flag == 0);
+ _CLS();
+ _LOCATE(0,0);
+ printstr("Formatting...");
c = pop_keyinfifo();
format_eeprom(0,254);
/* Check EEPROM */
/* Push default parameters to AKC6955*/
scanflag = 0;
-#ifndef _LCD_DEBUG
+#if 0
akc6955_chg_fm(fm); // Set to AM
akc6955_set_amband(amband);
akc6955_set_freq(amfreq); // Dummy, TBS (954KHz)
akc6955_set_power(0xff); // Power ON
#endif
-#ifdef _LCD_DEBUG
+#if 0
idle(0xf000);
#else
idle(0xff00);
#endif
_CLS();
- update_status();
+ //update_status();
update_display();
do {
/* Main routine*/
if(input_flag != 0){
readchar = pop_keyinfifo();
if((readchar >= charcode_1) && (readchar <= charcode_f)) {
- setfreq_updown(readchar);
+ // setfreq_updown(readchar);
} else {
// Other is skip
}
}
// Check battery (include idle?)
// Read AKJC6955's status
- update_status();
+// update_status();
// Putstring to LCD.
update_display();
} else {
power_flag = 0xff;
}
- setsignal_tune(power_flag);
+// setsignal_tune(power_flag);
#endif
idle(ui_idlecount);
} while(1);
keyin_now.byte[i] = 0x00;
}
/* SCANLINE A*/
- latchvar = LATA | 0x02;
+ latchvar = (LATA | 0x0f) & 0xfe;
LATA = latchvar;
- portvar = PORTA;
- low = (portvar & 0x3c) >>2;
- latchvar = LATA & 0xfd;
+ delay1ktcy(8); // 1ms
+ portvar = PORTB;
+ low = ~portvar & 0x0f;
+ latchvar |= 0x0f;
LATA = latchvar;
+ delay1ktcy(8); // 1ms
+
/* SCANLINE B*/
- latchvar = LATB | 0x02;
- LATB = latchvar;
- portvar = PORTA;
- high = (portvar & 0x3c) >>2;
- latchvar = LATB & 0xfd;
- LATB = latchvar;
+ latchvar &= 0xfd;
+ LATA = latchvar;
+ delay1ktcy(8); // 1ms
+ portvar = PORTB;
+ high = ~portvar & 0x0f;
+ latchvar |= 0x0f;
+ LATA = latchvar;
+ delay1ktcy(8); // 1ms
/* Pos */
+
keyin_now.byte[0] = (low << 4) | high;
- /* SCANLINE C*/
- latchvar = LATB | 0x04;
+ /* SCANLINE A*/
+ latchvar &= 0xfb;
LATA = latchvar;
- portvar = PORTA;
- low = (portvar & 0x3c) >>2;
- latchvar = LATB & 0xfb;
+ delay1ktcy(8); // 1ms
+ portvar = PORTB;
+ low = ~portvar & 0x0f;
+ latchvar |= 0x0f;
LATA = latchvar;
- /* SCANLINE D*/
- latchvar = LATB | 0x20;
- LATB = latchvar;
- portvar = PORTA;
- high = (portvar & 0x3c) >>2;
- latchvar = LATB & 0xdf;
- LATB = latchvar;
- /* Pos */
- keyin_now.byte[1] = (low << 4) | high;
+ delay1ktcy(8); // 1ms
+ /* SCANLINE B*/
+ latchvar &= 0xf7;
+ LATA = latchvar;
+ delay1ktcy(8); // 1ms
+ portvar = PORTB;
+ high = ~portvar & 0x0f;
+ latchvar |= 0x0f;
+ LATA = latchvar;
+ delay1ktcy(8); // 1ms
+ /* Pos */
+ keyin_now.byte[0] = (low << 4) | high;
/* Special KEYS */
- keyin_now.BIT0F = PORTBbits.RB1;
- keyin_now.BIT1F = PORTBbits.RB2;
- keyin_now.BIT2F = PORTBbits.RB3;
- keyin_now.BIT3F = 0; // Reserve
}
unsigned char readkey_compare(void)