示例#1
0
/**
 * Draw bars in different shades of grey, red, green and blue
 * used for calibrating the contrast and brightness
 */
void draw_contrast_brightness(void)
{
  const int CONTRAST_BRIGHTNESS_LEVELS[21] =
    {
      0, 17, 27, 38, 48, 59, 70, 82, 94, 106, 119, 131,
      144, 158, 171, 185, 198, 212, 226, 241, 255
    };
  size_t f;
  uint32_t y, x;
  for (f = 0; f < framebuffer_count; f++)
    {
      framebuffer_t* restrict fb = framebuffers + f;
      for (y = 0; y < 4; y++)
        for (x = 0; x < 21; x++)
          {
            int v = CONTRAST_BRIGHTNESS_LEVELS[x];
            uint32_t colour = fb_colour(v * ((y == 1) | (y == 0)),
                                        v * ((y == 2) | (y == 0)),
                                        v * ((y == 3) | (y == 0)));
            fb_fill_rectangle(fb, colour,
                              x * fb->width / 21,
                              y * fb->height / 4,
                              (x + 1) * fb->width / 21 - x * fb->width / 21,
                              (y + 1) * fb->height / 4 - y * fb->height / 4);
          }
    }
}
示例#2
0
void main() {
    int x, y, c;
    struct timer_wait tw;
    int led_status = LOW;

    // Default screen resolution (set in config.txt or auto-detected)
    //fb_init(0, 0);

    // Sets a specific screen resolution
    fb_init(32 + 320 + 32, 32 + 200 + 32);

    fb_fill_rectangle(0, 0, fb_width - 1, fb_height - 1, BORDER_COLOR);

    initscr(40, 25);
    cur_fore = WHITE;
    cur_back = BACKGROUND_COLOR;
    clear();

    mvaddstr(1, 9, "**** RASPBERRY-PI ****");
    mvaddstr(3, 7, "BARE-METAL SYSTEM TEMPLATE\r\n");

    if (mount("sd:") != 0) {
        addstrf("\r\nSD CARD NOT MOUNTED (%s)\r\n", strerror(errno));
    }

    usb_init();
    if (keyboard_init() != 0) {
        addstr("\r\nNO KEYBOARD DETECTED\r\n");
    }

    pinMode(16, OUTPUT);
    register_timer(&tw, 250000);

    addstr("\r\nREADY\r\n");

    while(1) {
        if ((c = getch()) != -1) {
            switch(c) {
                case KEY_UP:
                    getyx(y, x);
                    move(y - 1, x);
                    break;
                case KEY_DOWN:
                    getyx(y, x);
                    move(y + 1, x);
                    break;
                case KEY_LEFT:
                    getyx(y, x);
                    x--;
                    if (x < 0) {
                        x = 39;
                        y--;
                    }
                    move(y, x);
                    break;
                case KEY_RIGHT:
                    getyx(y, x);
                    x++;
                    if (x >= 40) {
                        x = 0;
                        y++;
                    }
                    move(y, x);
                    break;
                case KEY_HOME:
                    getyx(y, x);
                    move(y, 0);
                    break;
                case KEY_PGUP:
                    move(0, 0);
                    break;
                case '\r':
                    addch(c);
                    addch('\n');
                    break;
                default:
                    if (c < 0x7F) {
                        addch(c);
                    }
                    break;
            }
        }

        if (compare_timer(&tw)) {
            led_status = led_status == LOW ? HIGH : LOW;
            digitalWrite(16, led_status);
            toggle_cursor();
        }

        refresh();
    }
}