Exemplo n.º 1
0
void oled_draw_rect(uint8 x, uint8 y, uint8 w, uint8 h, uint8 *data)
{
    Set_Column_Address(x, x+w-1);
    Set_Row_Address(y, y+h-1);
    write_c(SSD1351_CMD_WRITERAM);
    write_d_stream(data, w*h*BPP);
}
Exemplo n.º 2
0
Arquivo: perf.cpp Projeto: adan/misc
int main(int argc, char* argv[])
{
	if (argc > 1) {
		int i, n = atoi(argv[1]);
		if (argc == 2) {
			for (i = 0; i < n; ++i) {
				write(i);
			}
		}
		else if (argv[2][1] == 'e') {
			for (i = 0; i < n; ++i) {
				write_e(i);
			}
		}
		else if (argv[2][1] == 'c') {
			for (i = 0; i < n; ++i) {
				write_c(i);
			}
		}
		else if (argv[2][1] == 'n') {
			for (i = 0; i < n; ++i) {
				write_n(i);
			}
		}
	}
	return 0;
}
Exemplo n.º 3
0
static void Set_Display_Mode(unsigned char d) {
    write_c(0xA4|d);    // Set Display Mode
                        //   Default => 0xA6
                        //     0xA4 (0x00) => Entire Display Off, All Pixels Turn Off
                        //     0xA5 (0x01) => Entire Display On, All Pixels Turn On at GS Level 63
                        //     0xA6 (0x02) => Normal Display
                        //     0xA7 (0x03) => Inverse Display
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
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.
}
Exemplo n.º 6
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
}
Exemplo n.º 7
0
extern void
_write_s(int offset, int len, uint8 * str)
{
	int i;

	for (i = 0; i < len; i++)
	{
		write_c(i + offset, str[i]);
	}
}
Exemplo n.º 8
0
//=========================================================
// Clear OLED GDRAM
//=========================================================
void CLS(uint16 color) {
  Home();
  write_c(SSD1351_CMD_WRITERAM);    // Enable MCU to Write to RAM

  uint8_t c[256];
  for(uint32_t i=0;i<256;i++) c[i] = color;

  for(uint32_t j=0;j<128;j++) {
    oled_draw_rect(0,j,128,1,c);
  }
}
Exemplo n.º 9
0
ssize_t send_msg_group(client_t* client, msg_group_t* g)
{
    size_t i;
    ssize_t written, ret = 0;
    size_t left, fixed;
    if (g->count == 0) return -1;

    left = msg_data_length(g->elements[0]);
    fixed = qtun->max_length;
    for (i = 0; i < g->count - 1UL; ++i)
    {
        written = write_c(client, g->elements[i], sizeof(msg_t) + fixed);
        if (written <= 0) return written;
        ret  += written;
        left -= fixed;
    }
    written = write_c(client, g->elements[g->count - 1], sizeof(msg_t) + left);
    if (written <= 0) return written;
    return ret + written;
}
Exemplo n.º 10
0
static void server_process_sys(client_t* client, msg_t* msg)
{
    switch (GET_SYS_OP(msg->sys))
    {
    case SYS_PING:
        if (IS_SYS_REQUEST(msg->sys))
        {
            client->keepalive = (unsigned int)time(NULL);
            msg_t* new_msg = new_keepalive_msg(0);
            write_c(client, new_msg, sizeof(msg_t));
            SYSLOG(LOG_INFO, "reply keepalive message");
            pool_room_free(&this.pool, MSG_ROOM_IDX);
        }
        break;
    }
}
Exemplo n.º 11
0
static void Set_Display_Offset(unsigned char d) {
    write_c(0xA2);           // Set Vertical Scroll by Row
    write_d(d);              //   Default => 0x60
}
Exemplo n.º 12
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)
}
Exemplo n.º 13
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)
}
Exemplo n.º 14
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
}
Exemplo n.º 15
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
}
Exemplo n.º 16
0
void menu_func_OLED_addjust_brightness(){
	while(!JOY_button(1)){
		write_c(0x81);
		write_c(JOY_slider(1));		
	}	
}
Exemplo n.º 17
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);
}
Exemplo n.º 18
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)
}
Exemplo n.º 19
0
void Set_Master_Current(unsigned char d) {
    write_c(0xC7);            // Master Contrast Current Control
    write_d(d);              //   Default => 0x0F (Maximum)
}
Exemplo n.º 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
}
Exemplo n.º 21
0
static void Set_Display_Off() {
    write_c(0xAE);
}
Exemplo n.º 22
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)
}
Exemplo n.º 23
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)
}
Exemplo n.º 24
0
static void Set_GPIO(unsigned char d) {
    write_c(0xB5);            // General Purpose IO
    write_d(d);              //   Default => 0x0A (GPIO Pins output Low Level.)
}
Exemplo n.º 25
0
static void Set_Start_Line(unsigned char d) {
    write_c(0xA1);           // Set Vertical Scroll by RAM
    write_d(d);              //   Default => 0x00
}
Exemplo n.º 26
0
static void Set_Multiplex_Ratio(unsigned char d) {
    write_c(0xCA);            // Set Multiplex Ratio
    write_d(d);              //   Default => 0x7F (1/128 Duty)
}
Exemplo n.º 27
0
//Initializes the OLED screen with a blank screen
void oled_init(){
	write_c(0xae); // display off
	write_c(0xa1); //segment remap
	write_c(0xda); //common pads hardware: alternative
	write_c(0x12);
	write_c(0xc8); //common output scan direction:com63~com0
	write_c(0xa8); //multiplex ration mode:63
	write_c(0x3f);
	write_c(0xd5); //display divide ratio/osc. freq. mode
	write_c(0x80);
	write_c(0x81); //contrast control
	write_c(0x50);
	write_c(0xd9); //set pre-charge period
	write_c(0x21);
	write_c(0x20); //Set Memory Addressing Mode
	write_c(0x02);
	write_c(0xdb); //VCOM deselect level mode
	write_c(0x30);
	write_c(0xad); //master configuration
	write_c(0x00);
	write_c(0xa4); //out follows RAM content
	write_c(0xa6); //set normal display
	write_c(0xaf); // display on

	// Clear screen
	oled_clear_screen();
}
Exemplo n.º 28
0
static void Set_Display_On() {
    write_c(0xAF);
}
Exemplo n.º 29
0
static void Set_VCOMH(unsigned char d) {
    write_c(0xBE);            // Set COM Deselect Voltage Level
    write_d(d);              //   Default => 0x05 (0.82*VCC)
}
Exemplo n.º 30
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
}