Example #1
0
static void Set_VSL(unsigned char d) {
    write_c(0xB4);   // Set Segment Low Voltage
    write_d(0xA0|d); //   Default => 0xA0
                     //     0xA0 (0x00) => Enable External VSL
                     //     0xA2 (0x02) => Enable Internal VSL (Kept VSL Pin N.C.)
    write_d(0xB5);
    write_d(0x55);
}
Example #2
0
void oled_clear_line(){
	int i;
	for(i = 0; i < 128; i++){
		write_d(0x00);
	}
	//Jump to first column
	oled_changeColumn(0);
	
}
Example #3
0
void Set_Command_Lock(unsigned char d)
{
    write_c(0xFD);            // Set Command Lock
    write_d(d);              //   Default => 0x12
                        //     0x12 => Driver IC interface is unlocked from entering command.
                        //     0x16 => All Commands are locked except 0xFD.
                        //     0xB0 => Command 0xA2, 0xB1, 0xB3, 0xBB & 0xBE are inaccessible.
                        //     0xB1 => All Commands are accessible.
}
Example #4
0
static void Set_Remap_Format(unsigned char d) {
    write_c(0xA0);      // Set Re-Map / Color Depth
    write_d(d);         //   Default => 0x40
                        //     Horizontal Address Increment
                        //     Column Address 0 Mapped to SEG0
                        //     Color Sequence: A => B => C
                        //     Scan from COM0 to COM[N-1]
                        //     Disable COM Split Odd Even
                        //     65,536 Colors
}
Example #5
0
static char *write_u(char *p, char *ebuf, const knh_ldata2_t *d)
{
	if(ebuf - p < 32) return NULL;
	kuintptr_t u = d->uvalue / 10, r = d->uvalue % 10;
	if(u != 0) {
		p = write_d(p, ebuf, u);
	}
	p[0] = ('0' + r);
	return p + 1;
}
Example #6
0
void oled_clear_screen(){
	int i, j;
	for(i = 0; i < 8; i++){
		oled_goto_line(i);
		for(j = 0; j < 256; j++){
			write_d(0b00000000);
		}
	}
	
	//Jump to first line
	oled_goto_line(0);
}
Example #7
0
static char *write_i(char *p, char *ebuf, const knh_ldata2_t *d)
{
	if(ebuf - p < 32) return NULL;
	kuintptr_t uvalue = d->uvalue;
	if(d->ivalue < 0) {
		p[0] = '-'; p++;
		uvalue = -(d->ivalue);
	}
	kuintptr_t u = uvalue / 10, r = uvalue % 10;
	if(u != 0) {
		p = write_d(p, ebuf, u);
	}
	p[0] = ('0' + r);
	return p + 1;
}
Example #8
0
static char *write_f(char *p, char *ebuf, const knh_ldata2_t *d)
{
	if(ebuf - p < 32) return NULL;
	kuintptr_t uvalue = (kuintptr_t)d->ivalue;
	if(d->ivalue < 0) {
		p[0] = '-'; p++;
	}
	kuintptr_t u = uvalue / 1000, r = uvalue % 1000;
	if(u != 0) {
		p = write_d(p, ebuf, u);
	}
	else {
		p[0] = '0'; p++;
	}
	p[0] = '.'; p++;
	u = r / 100;
	p[0] = ('0' + (u)); p++;
	p[0] = ('0' + (u / 10)); p++;
	p[0] = ('0' + (u % 10));
	return p + 1;
}
Example #9
0
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//  Gray Scale Table Setting (Full Screen)
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
static void Set_Gray_Scale_Table()
{
    write_c(0xB8);
    write_d(0x02);           // Gray Scale Level 1
    write_d(0x03);           // Gray Scale Level 2
    write_d(0x04);           // Gray Scale Level 3
    write_d(0x05);           // Gray Scale Level 4
    write_d(0x06);           // Gray Scale Level 5
    write_d(0x07);           // Gray Scale Level 6
    write_d(0x08);           // Gray Scale Level 7
    write_d(0x09);           // Gray Scale Level 8
    write_d(0x0A);           // Gray Scale Level 9
    write_d(0x0B);           // Gray Scale Level 10
    write_d(0x0C);           // Gray Scale Level 11
    write_d(0x0D);           // Gray Scale Level 12
    write_d(0x0E);           // Gray Scale Level 13
    write_d(0x0F);           // Gray Scale Level 14
    write_d(0x10);           // Gray Scale Level 15
    write_d(0x11);           // Gray Scale Level 16
    write_d(0x12);           // Gray Scale Level 17
    write_d(0x13);           // Gray Scale Level 18
    write_d(0x15);           // Gray Scale Level 19
    write_d(0x17);           // Gray Scale Level 20
    write_d(0x19);           // Gray Scale Level 21
    write_d(0x1B);           // Gray Scale Level 22
    write_d(0x1D);           // Gray Scale Level 23
    write_d(0x1F);           // Gray Scale Level 24
    write_d(0x21);           // Gray Scale Level 25
    write_d(0x23);           // Gray Scale Level 26
    write_d(0x25);           // Gray Scale Level 27
    write_d(0x27);           // Gray Scale Level 28
    write_d(0x2A);           // Gray Scale Level 29
    write_d(0x2D);           // Gray Scale Level 30
    write_d(0x30);           // Gray Scale Level 31
    write_d(0x33);           // Gray Scale Level 32
    write_d(0x36);           // Gray Scale Level 33
    write_d(0x39);           // Gray Scale Level 34
    write_d(0x3C);           // Gray Scale Level 35
    write_d(0x3F);           // Gray Scale Level 36
    write_d(0x42);           // Gray Scale Level 37
    write_d(0x45);           // Gray Scale Level 38
    write_d(0x48);           // Gray Scale Level 39
    write_d(0x4C);           // Gray Scale Level 40
    write_d(0x50);           // Gray Scale Level 41
    write_d(0x54);           // Gray Scale Level 42
    write_d(0x58);           // Gray Scale Level 43
    write_d(0x5C);           // Gray Scale Level 44
    write_d(0x60);           // Gray Scale Level 45
    write_d(0x64);           // Gray Scale Level 46
    write_d(0x68);           // Gray Scale Level 47
    write_d(0x6C);           // Gray Scale Level 48
    write_d(0x70);           // Gray Scale Level 49
    write_d(0x74);           // Gray Scale Level 50
    write_d(0x78);           // Gray Scale Level 51
    write_d(0x7D);           // Gray Scale Level 52
    write_d(0x82);           // Gray Scale Level 53
    write_d(0x87);           // Gray Scale Level 54
    write_d(0x8C);           // Gray Scale Level 55
    write_d(0x91);           // Gray Scale Level 56
    write_d(0x96);           // Gray Scale Level 57
    write_d(0x9B);           // Gray Scale Level 58
    write_d(0xA0);           // Gray Scale Level 59
    write_d(0xA5);           // Gray Scale Level 60
    write_d(0xAA);           // Gray Scale Level 61
    write_d(0xAF);           // Gray Scale Level 62
    write_d(0xB4);           // Gray Scale Level 63
}
Example #10
0
static void ntrace(CTX ctx, const char *event, int pe, const knh_ldata2_t *d)
{
	char buf[EBUFSIZ], *p = buf, *ebuf =  p + (EBUFSIZ - 4);
	int logtype = LOG_NOTICE;
	p = write_b(p, ebuf, ctx->trace, strlen(ctx->trace));
	p[0] = '+'; p++;
	p = write_d(p, ebuf, ctx->seq);
	((kcontext_t*)ctx)->seq += 1;
	p[0] = ' '; p++;
	p = write_b(p, ebuf, event, strlen(event));
	if(pe % 2 == 1) {
		p = write_b(p, ebuf, "*FAILED* ", strlen("*FAILED* "));
		logtype = LOG_ERR;
	}
	else {
		p[0] = ' '; p++;
	}
	p[0] = '{'; p++;
	if(pe % 2 == 1 && ((pe & FLAG_TRACE_ERRNO) == FLAG_TRACE_ERRNO)) {
		int errno_ = errno;
		if(errno_ > 0) {
			p = write_key(p, ebuf, "errno");
			p = write_d(p, ebuf, errno_);
			p[0] = ','; p++; p[0] = ' '; p++;
			knh_ldata2_t d[1];
			d[0].svalue = strerror(errno_);
			if(d[0].svalue != NULL) {
				p = write_key(p, ebuf, "msg");
				p = write_s(p, ebuf, d);
				p[0] = ','; p++; p[0] = ' '; p++;
			}
		}
	}
	while(d->type != 0) {
		char *p2 = write_key(p, ebuf, d[1].key);
		if(p2 != NULL) {
			if(d->type == LOGT_sfp) {
				// TODO
				d+=2; continue;
			}
			DBG_ASSERT(d->type <= LOGT_o);
			p2 = writeldata[d->type](p2, ebuf, d+2);
			if(p2 != NULL) {
				p = write_comma(p2, ebuf, d+3);
			}
		}
		d += 3;
	}
	p[0] = '}'; p++;
	p[0] = 0;
	knh_syslog(logtype, (const char*)buf);
	if(isVerbose) {
		fputs(LOG__(logtype), stderr);
		fputs(" ", stderr);
		fputs(buf, stderr);
		fputs(K_OSLINEFEED, stderr);
		fflush(stderr);
	}
//	if(pe % 2 == 1) {
//
//	}
}
Example #11
0
static void Set_Multiplex_Ratio(unsigned char d) {
    write_c(0xCA);            // Set Multiplex Ratio
    write_d(d);              //   Default => 0x7F (1/128 Duty)
}
Example #12
0
void Set_Master_Current(unsigned char d) {
    write_c(0xC7);            // Master Contrast Current Control
    write_d(d);              //   Default => 0x0F (Maximum)
}
Example #13
0
static void Set_Contrast_Color(unsigned char a, unsigned char b, unsigned char c) {
    write_c(0xC1);           // Set Contrast Current for Color A, B, C
    write_d(a);              //   Default => 0x8A (Color A)
    write_d(b);              //   Default => 0x51 (Color B)
    write_d(c);              //   Default => 0x8A (Color C)
}
Example #14
0
static void Set_Display_Offset(unsigned char d) {
    write_c(0xA2);           // Set Vertical Scroll by Row
    write_d(d);              //   Default => 0x60
}
Example #15
0
static void Set_GPIO(unsigned char d) {
    write_c(0xB5);            // General Purpose IO
    write_d(d);              //   Default => 0x0A (GPIO Pins output Low Level.)
}
Example #16
0
static void Set_Precharge_Period(unsigned char d) {
    write_c(0xB6);            // Set Second Pre-Charge Period
    write_d(d);              //   Default => 0x08 (8 Display Clocks)
}
Example #17
0
static void Set_Display_Clock(unsigned char d) {
    write_c(0xB3);   // Set Display Clock Divider / Oscillator Frequency
    write_d(d);      //   Default => 0x00
                     //     A[3:0] => Display Clock Divider
                     //     A[7:4] => Oscillator Frequency
}
Example #18
0
//Takes in a char and prints it at current position
//SMALL SIZE
void oled_print_char(char c){
	int i;
	for(i=0;i<5;i++){
		write_d(pgm_read_byte(&font[(int) c -32][i]));
	}		
}
Example #19
0
static void Set_Display_Enhancement(unsigned char d) {
    write_c(0xB2);      // Display Enhancement
    write_d(d);         //   Default => 0x00 (Normal)
    write_d(0x00);
    write_d(0x00);
}
Example #20
0
static void Set_Phase_Length(unsigned char d) {
    write_c(0xB1);            // Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment
    write_d(d);              //   Default => 0x82 (8 Display Clocks [Phase 2] / 5 Display Clocks [Phase 1])
                        //     D[3:0] => Phase 1 Period in 5~31 Display Clocks
                        //     D[7:4] => Phase 2 Period in 3~15 Display Clocks
}
Example #21
0
static void Set_Function_Selection(unsigned char d) {
    write_c(0xAB);            // Function Selection
    write_d(d);              //   Default => 0x01
                        //     Enable Internal VDD Regulator
                        //     Select 8-bit Parallel Interface
}
Example #22
0
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//  Instruction Setting
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Set_Column_Address(unsigned char a, unsigned char b) {
    write_c(0x15);            // Set Column Address
    write_d(a);              //   Default => 0x00 (Start Address)
    write_d(b);              //   Default => 0x7F (End Address)
}
Example #23
0
static void Set_Precharge_Voltage(unsigned char d) {
    write_c(0xBB);            // Set Pre-Charge Voltage Level
    write_d(d);              //   Default => 0x17 (0.50*VCC)
}
Example #24
0
void Set_Row_Address(unsigned char a, unsigned char b) {
    write_c(0x75);            // Set Row Address
    write_d(a);              //   Default => 0x00 (Start Address)
    write_d(b);              //   Default => 0x7F (End Address)
}
Example #25
0
static void Set_VCOMH(unsigned char d) {
    write_c(0xBE);            // Set COM Deselect Voltage Level
    write_d(d);              //   Default => 0x05 (0.82*VCC)
}
Example #26
0
static void Set_Start_Line(unsigned char d) {
    write_c(0xA1);           // Set Vertical Scroll by RAM
    write_d(d);              //   Default => 0x00
}
Example #27
0
//Takes in a char and prints it at current position
//MEDIUM SIZE
void oled_print_char_medium(char c){
	int i;
	for(i=0;i<8;i++){
		write_d(pgm_read_byte(&font_medium[(int) c -32][i]));
	}
}