Ejemplo n.º 1
0
static int read_only_image(int argc, char *argv[], void *userdata) {
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        int b = true, r;

        if (argc > 2) {
                b = parse_boolean(argv[2]);
                if (b < 0)
                        return log_error_errno(b, "Failed to parse boolean argument: %s", argv[2]);
        }

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

        r = sd_bus_call_method(
                        bus,
                        "org.freedesktop.portable1",
                        "/org/freedesktop/portable1",
                        "org.freedesktop.portable1.Manager",
                        "MarkImageReadOnly",
                        &error,
                        NULL,
                        "sb", argv[1], b);
        if (r < 0)
                return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, r));

        return 0;
}
Ejemplo n.º 2
0
	LLDSPEC	void gdisp_lld_write_start(GDisplay *g) {
		acquire_bus(g);
		set_viewport(g);
		#if !GDISP_HARDWARE_STREAM_POS
			set_cursor(g);
		#endif
	}
Ejemplo n.º 3
0
static int detach_image(int argc, char *argv[], void *userdata) {
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        _cleanup_free_ char *image = NULL;
        int r;

        r = determine_image(argv[1], true, &image);
        if (r < 0)
                return r;

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

        r = sd_bus_call_method(
                        bus,
                        "org.freedesktop.portable1",
                        "/org/freedesktop/portable1",
                        "org.freedesktop.portable1.Manager",
                        "DetachImage",
                        &error,
                        &reply,
                        "sb", image, arg_runtime);
        if (r < 0)
                return log_error_errno(r, "Failed to detach image: %s", bus_error_message(&error, r));

        (void) maybe_reload(&bus);

        print_changes(reply);
        return 0;
}
Ejemplo n.º 4
0
	LLDSPEC	void gdisp_lld_read_start(GDisplay *g) {
		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);
		setreadmode(g);
		dummy_read(g);
	}
Ejemplo n.º 5
0
static int maybe_reload(sd_bus **bus) {
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
        int r;

        if (!arg_reload)
                return 0;

        r = acquire_bus(bus);
        if (r < 0)
                return r;

        r = sd_bus_message_new_method_call(
                        *bus,
                        &m,
                        "org.freedesktop.systemd1",
                        "/org/freedesktop/systemd1",
                        "org.freedesktop.systemd1.Manager",
                        "Reload");
        if (r < 0)
                return bus_log_create_error(r);

        /* Reloading the daemon may take long, hence set a longer timeout here */
        r = sd_bus_call(*bus, m, DEFAULT_TIMEOUT_USEC * 2, &error, NULL);
        if (r < 0)
                return log_error_errno(r, "Failed to reload daemon: %s", bus_error_message(&error, r));

        return 0;
}
	LLDSPEC void gdisp_lld_flush(GDisplay *g) {
		uint8_t * ram;
		unsigned pages;

		// Don't flush if we don't need it.
		if (!(g->flags & GDISP_FLG_NEEDFLUSH))
			return;
		ram = RAM(g);
		pages = GDISP_SCREEN_HEIGHT/8;

		acquire_bus(g);
		write_cmd(g, SSD1306_SETSTARTLINE | 0);

		while (pages--) {
			#if SSD1306_SH1106
				write_cmd(g, SSD1306_PAM_PAGE_START + (7 - pages));
				write_cmd(g, SSD1306_SETLOWCOLUMN + 2);
				write_cmd(g, SSD1306_SETHIGHCOLUMN);
			#endif

			write_data(g, ram, SSD1306_PAGE_WIDTH);
			ram += SSD1306_PAGE_WIDTH;
		}
		release_bus(g);

		g->flags &= ~GDISP_FLG_NEEDFLUSH;
	}
Ejemplo n.º 7
0
static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
    (void)argc;
    (void)argv;

    acquire_bus();

    write_index(0x00);
    chprintf(chp,"Device ID %x\r\n",read_data());
    release_bus();
    //chprintf(chp,"GRAM %x\r\n",gdispReadReg(0x22));
 
    /*gdispClear(White);
    chThdSleepMilliseconds(3000);
    gdispClear(Red);
    chThdSleepMilliseconds(3000);
    gdispClear(Blue);
    chThdSleepMilliseconds(3000);
    gdispClear(Green);*/
    #if 0
    uint8_t c = 0xAA;
    uint8_t d = 0x55;

    spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
    spiStart(&SPID1, &spicfg);       /* Setup transfer parameters.       */
    spiSelect(&SPID1);                  /* Slave Select assertion.          */

    spiSend(&SPID1, 1, &c);
    spiSend(&SPID1, 1, &d);

    spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);              /* Ownership release.               */
    #endif
}
Ejemplo n.º 8
0
	/**
	 * @brief   Fill an area with a bitmap.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] x, y     The start filled area
	 * @param[in] cx, cy   The width and height to be filled
	 * @param[in] srcx, srcy   The bitmap position to start the fill from
	 * @param[in] srccx    The width of a line in the bitmap.
	 * @param[in] buffer   The pixels to use to fill the area.
	 *
	 * @notapi
	 */
	void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) {
		coord_t endx, endy;
		unsigned lg;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (srcx+cx > srccx)		cx = srccx - srcx;
			if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		acquire_bus();
		set_viewport(x, y, cx, cy);
		stream_start();

		endx = srcx + cx;
		endy = y + cy;
		lg = srccx - cx;
		buffer += srcx + srcy * srccx;
		for(; y < endy; y++, buffer += lg)
			for(x=srcx; x < endx; x++)
				write_data(*buffer++);
		stream_stop();
		reset_viewport();
		release_bus();
	}
	LLDSPEC	void gdisp_lld_read_start(GDisplay *g) {
		acquire_bus(g);
		//set_viewport(g);
		//write_index(g, 0x2E);
		setreadmode(g);
		//dummy_read(g);
	}
Ejemplo n.º 10
0
static int dump_profiles(void) {
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        _cleanup_strv_free_ char **l = NULL;
        char **i;
        int r;

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        r = sd_bus_get_property_strv(
                        bus,
                        "org.freedesktop.portable1",
                        "/org/freedesktop/portable1",
                        "org.freedesktop.portable1.Manager",
                        "Profiles",
                        &error,
                        &l);
        if (r < 0)
                return log_error_errno(r, "Failed to acquire list of profiles: %s", bus_error_message(&error, r));

        if (arg_legend)
                log_info("Available unit profiles:");

        STRV_FOREACH(i, l) {
                fputs(*i, stdout);
                fputc('\n', stdout);
        }
Ejemplo n.º 11
0
/**
 * @brief   Fill an area with a color.
 * @note    Optional - The high level driver can emulate using software.
 *
 * @param[in] x, y     The start filled area
 * @param[in] cx, cy   The width and height to be filled
 * @param[in] color    The color of the fill
 *
 * @notapi
 */
void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
    unsigned i, area;

#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
    if (x < GDISP.clipx0) {
        cx -= GDISP.clipx0 - x;
        x = GDISP.clipx0;
    }
    if (y < GDISP.clipy0) {
        cy -= GDISP.clipy0 - y;
        y = GDISP.clipy0;
    }
    if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
    if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
    if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
#endif

    area = cx*cy;
    acquire_bus();
    set_viewport(x, y, cx, cy);
    stream_start();
    for(i = 0; i < area; i++)
        write_data(color);
    stream_stop();
    reset_viewport();
    release_bus();
}
Ejemplo n.º 12
0
	LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
		uint16_t	c;

		c = gdispColor2Native(g->p.color);
		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);
		dma_with_noinc(g, &c, g->p.cx*g->p.cy);
		release_bus(g);
	}
Ejemplo n.º 13
0
/**
 * @brief   Draws a pixel on the display.
 *
 * @param[in] x        X location of the pixel
 * @param[in] y        Y location of the pixel
 * @param[in] color    The color of the pixel
 *
 * @notapi
 */
void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
	#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
		if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
	#endif

	acquire_bus();
	set_cursor(x, y);
	write_reg(0x0022, color);
	release_bus();
}
Ejemplo n.º 14
0
	LLDSPEC	void gdisp_lld_write_start(GDisplay *g) {
		acquire_bus(g);
		write_cmd(g, SSD1327_SET_COLUMN_ADDRESS);
		write_data(g, g->p.x);
		write_data(g, g->p.x + g->p.cx - 1);
		write_cmd(g, SSD1327_SET_ROW_ADDRESS);
		write_data(g, g->p.y);
		write_data(g, g->p.y + g->p.cy - 1);
		write_cmd(g, SSD1327_WRITE_RAM);
	}
Ejemplo n.º 15
0
	/**
	 * @brief   Scroll vertically a section of the screen.
	 * @note    Optional.
	 * @note    If x,y + cx,cy is off the screen, the result is undefined.
	 * @note    If lines is >= cy, it is equivelent to a area fill with bgcolor.
	 *
	 * @param[in] x, y     The start of the area to be scrolled
	 * @param[in] cx, cy   The size of the area to be scrolled
	 * @param[in] lines    The number of lines to scroll (Can be positive or negative)
	 * @param[in] bgcolor  The color to fill the newly exposed area.
	 *
	 * @notapi
	 */
	void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
		/* This is marked as "TODO: Test this" in the original GLCD driver.
		 * For now we just leave the GDISP_HARDWARE_SCROLL off.
		 */
		static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)];
		coord_t row0, row1;
		unsigned i, gap, abslines;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		abslines = lines < 0 ? -lines : lines;

		acquire_bus();
		if (abslines >= cy) {
			abslines = cy;
			gap = 0;
		} else {
			gap = cy - abslines;
			for(i = 0; i < gap; i++) {
				if(lines > 0) {
					row0 = y + i + lines;
					row1 = y + i;
				} else {
					row0 = (y - i - 1) + lines;
					row1 = (y - i - 1);
				}

				/* read row0 into the buffer and then write at row1*/
				set_viewport(x, row0, cx, 1);
				lld_lcdReadStreamStart();
				lld_lcdReadStream(buf, cx);
				lld_lcdReadStreamStop();

				set_viewport(x, row1, cx, 1);
				stream_start();
				write_data(buf, cx);
				stream_stop();
			}
		}

		/* fill the remaining gap */
		set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines);
		stream_start();
		gap = cx*abslines;
		for(i = 0; i < gap; i++) write_data(bgcolor);
		stream_stop();
		reset_viewport();
		release_bus();
	}
Ejemplo n.º 16
0
	/**
	 * @brief   Scroll vertically a section of the screen.
	 * @note    Optional.
	 * @note    If x,y + cx,cy is off the screen, the result is undefined.
	 * @note    If lines is >= cy, it is equivelent to a area fill with bgcolor.
	 *
	 * @param[in] x, y     The start of the area to be scrolled
	 * @param[in] cx, cy   The size of the area to be scrolled
	 * @param[in] lines    The number of lines to scroll (Can be positive or negative)
	 * @param[in] bgcolor  The color to fill the newly exposed area.
	 *
	 * @notapi
	 */
	void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
		static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)];
		coord_t row0, row1;
		unsigned i, gap, abslines, j;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		abslines = lines < 0 ? -lines : lines;

		acquire_bus();
		if (abslines >= cy) {
			abslines = cy;
			gap = 0;
		} else {
			gap = cy - abslines;
			for(i = 0; i < gap; i++) {
				if(lines > 0) {
					row0 = y + i + lines;
					row1 = y + i;
				} else {
					row0 = (y - i - 1) + lines;
					row1 = (y - i - 1);
				}

				/* read row0 into the buffer and then write at row1*/
				set_viewport(x, row0, cx, 1);
				stream_start();
				j = read_data();			// dummy read
				for (j = 0; j < cx; j++)
					buf[j] = read_data();
				stream_stop();

				set_viewport(x, row1, cx, 1);
				stream_start();
				for (j = 0; j < cx; j++)
					write_data(buf[j]);
				stream_stop();
			}
		}

		/* fill the remaining gap */
		set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines);
		stream_start();
		gap = cx*abslines;
		for(i = 0; i < gap; i++) write_data(bgcolor);
		stream_stop();
		release_bus();
	}
Ejemplo n.º 17
0
	/**
	 * @brief   Clear the display.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] color    The color of the pixel
	 *
	 * @notapi
	 */
	void lld_gdisp_clear(color_t color) {
		unsigned i;

		acquire_bus();
		reset_viewport();
		set_cursor(0, 0);
		stream_start();
		for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++)
			write_data(color);
		stream_stop();
		release_bus();
	}
Ejemplo n.º 18
0
static int attach_image(int argc, char *argv[], void *userdata) {
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        _cleanup_strv_free_ char **matches = NULL;
        _cleanup_free_ char *image = NULL;
        int r;

        r = determine_image(argv[1], false, &image);
        if (r < 0)
                return r;

        r = determine_matches(argv[1], argv + 2, false, &matches);
        if (r < 0)
                return r;

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

        r = sd_bus_message_new_method_call(
                                bus,
                                &m,
                                "org.freedesktop.portable1",
                                "/org/freedesktop/portable1",
                                "org.freedesktop.portable1.Manager",
                                "AttachImage");
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append(m, "s", image);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append_strv(m, matches);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append(m, "sbs", arg_profile, arg_runtime, arg_copy_mode);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_call(bus, m, 0, &error, &reply);
        if (r < 0)
                return log_error_errno(r, "Failed to attach image: %s", bus_error_message(&error, r));

        (void) maybe_reload(&bus);

        print_changes(reply);
        return 0;
}
Ejemplo n.º 19
0
	/**
	 * @brief   Clear the display.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] color    The color of the pixel
	 *
	 * @notapi
	 */
	void GDISP_LLD(clear)(color_t color) {
	    unsigned i;

		acquire_bus();
	    set_cursor(0, 0);
	    stream_start();

	    for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++)
	    	write_data(color);

	    stream_stop();
		release_bus();
	}
Ejemplo n.º 20
0
	LLDSPEC void gdisp_lld_fill_area(GDisplay* g) {
		#if GDISP_NO_DMA_FROM_STACK
			static LLDCOLOR_TYPE	c;
		#else
			LLDCOLOR_TYPE	c;
		#endif

		c = gdispColor2Native(g->p.color);
		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);	
		dma_with_noinc(g, &c, g->p.cx * g->p.cy);
		release_bus(g);
	}
Ejemplo n.º 21
0
static int set_limit(int argc, char *argv[], void *userdata) {
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        uint64_t limit;
        int r;

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

        if (STR_IN_SET(argv[argc-1], "-", "none", "infinity"))
                limit = (uint64_t) -1;
        else {
                r = parse_size(argv[argc-1], 1024, &limit);
                if (r < 0)
                        return log_error_errno(r, "Failed to parse size: %s", argv[argc-1]);
        }

        if (argc > 2)
                /* With two arguments changes the quota limit of the specified image */
                r = sd_bus_call_method(
                                bus,
                                "org.freedesktop.portable1",
                                "/org/freedesktop/portable1",
                                "org.freedesktop.portable1.Manager",
                                "SetImageLimit",
                                &error,
                                NULL,
                                "st", argv[1], limit);
        else
                /* With one argument changes the pool quota limit */
                r = sd_bus_call_method(
                                bus,
                                "org.freedesktop.portable1",
                                "/org/freedesktop/portable1",
                                "org.freedesktop.portable1.Manager",
                                "SetPoolLimit",
                                &error,
                                NULL,
                                "t", limit);

        if (r < 0)
                return log_error_errno(r, "Could not set limit: %s", bus_error_message(&error, r));

        return 0;
}
Ejemplo n.º 22
0
	/**
	 * @brief   Get the color of a particular pixel.
	 * @note    Optional.
	 * @note    If x,y is off the screen, the result is undefined.
	 *
	 * @param[in] x, y     The pixel to be read
	 *
	 * @notapi
	 */
	color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) {
		color_t color;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0;
		#endif

		acquire_bus();
		set_cursor(x, y);
		stream_start();
		color = read_data();			// dummy read
		color = read_data();
		stream_stop();
		release_bus();

		return color;
	}
Ejemplo n.º 23
0
	LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
		pixel_t		*buffer;
		coord_t		ycnt;

		buffer = (pixel_t *)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;

		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);
		if (g->p.x2 == g->p.cx) {
			dma_with_inc(g, buffer, g->p.cx*g->p.cy);
		} else {
			for (ycnt = g->p.cy; ycnt; ycnt--, buffer += g->p.x2)
				dma_with_inc(g, buffer, g->p.cy);
		}
		release_bus(g);
	}
Ejemplo n.º 24
0
 LLDSPEC void gdisp_lld_clear(GDisplay *g) {
   acquire_bus(g);
   write_cmd(g, SSD1327_SET_COLUMN_ADDRESS);
   write_data(g, 0);
   write_data(g, GDISP_SCREEN_WIDTH - 1);
   write_cmd(g, SSD1327_SET_ROW_ADDRESS);
   write_data(g, 0);
   write_data(g, GDISP_SCREEN_HEIGHT - 1);
   write_cmd(g, SSD1327_WRITE_RAM);
   LLDCOLOR_TYPE c;
   c = gdispColor2Native(g->p.color);
   uint16_t i = 0;
   for (i = 0; i < GDISP_SCREEN_WIDTH*GDISP_SCREEN_HEIGHT; i++)
   {
     write_data(g, c >> 8);
     write_data(g, c & 0xFF);
   }
   release_bus(g);
 }
Ejemplo n.º 25
0
LLDSPEC bool_t gdisp_lld_init(GDisplay *g)
{
	// No private area for this controller
	g->priv = 0;

	// Initialise the board interface
	init_board(g);

	// Hardware reset
	setpin_reset(g, TRUE);
	delayms(100);
	setpin_reset(g, FALSE);
	delayms(100);

	acquire_bus(g);

	const uint16_t *list = &lcd_init_list[0];
	uint8_t size = sizeof(lcd_init_list) / sizeof(lcd_init_list[0]);

	while(size--) {
		write_index(g, *list++);
	}

	// Finish Init
	post_init_board(g);

	release_bus(g);

	// Turn on the back-light
	set_backlight(g, GDISP_INITIAL_BACKLIGHT);

	// Initialise the GDISP structure to match 
	g->g.Width = GDISP_SCREEN_WIDTH;
	g->g.Height = GDISP_SCREEN_HEIGHT;
	g->g.Orientation = GDISP_ROTATE_0;
	g->g.Powermode = powerOn;
	g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
	g->g.Contrast = GDISP_INITIAL_CONTRAST;

	return TRUE;
}
Ejemplo n.º 26
0
  LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
    coord_t x = g->p.x;
    coord_t y = g->p.y;
    coord_t w = g->p.cx;
    coord_t h = g->p.cy;
    LLDCOLOR_TYPE c = g->p.color;

    acquire_bus(g);
    write_cmd(g, SSD1327_SET_COLUMN_ADDRESS);
    write_data(g, x);
    write_data(g, x + w -1);
    write_cmd(g, SSD1327_SET_ROW_ADDRESS);
    write_data(g, y);
    write_data(g, y + h - 1);
    write_cmd(g, SSD1327_WRITE_RAM);
    uint16_t i = 0;
    for (i = 0; i < w*h; i++)
    {
      write_data(g, c >> 8);
      write_data(g, c & 0xFF);
    }
    release_bus(g);
  }
Ejemplo n.º 27
0
static int is_image_attached(int argc, char *argv[], void *userdata) {
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        _cleanup_free_ char *image = NULL;
        const char *state;
        int r;

        r = determine_image(argv[1], true, &image);
        if (r < 0)
                return r;

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        r = sd_bus_call_method(
                        bus,
                        "org.freedesktop.portable1",
                        "/org/freedesktop/portable1",
                        "org.freedesktop.portable1.Manager",
                        "GetImageState",
                        &error,
                        &reply,
                        "s", image);
        if (r < 0)
                return log_error_errno(r, "Failed to get image state: %s", bus_error_message(&error, r));

        r = sd_bus_message_read(reply, "s", &state);
        if (r < 0)
                return r;

        if (!arg_quiet)
                puts(state);

        return streq(state, "detached");
}
Ejemplo n.º 28
0
static int remove_image(int argc, char *argv[], void *userdata) {
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
        int r, i;

        r = acquire_bus(&bus);
        if (r < 0)
                return r;

        (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

        for (i = 1; i < argc; i++) {
                _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
                _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;

                r = sd_bus_message_new_method_call(
                                bus,
                                &m,
                                "org.freedesktop.portable1",
                                "/org/freedesktop/portable1",
                                "org.freedesktop.portable1.Manager",
                                "RemoveImage");
                if (r < 0)
                        return bus_log_create_error(r);

                r = sd_bus_message_append(m, "s", argv[i]);
                if (r < 0)
                        return bus_log_create_error(r);

                /* This is a slow operation, hence turn off any method call timeouts */
                r = sd_bus_call(bus, m, USEC_INFINITY, &error, NULL);
                if (r < 0)
                        return log_error_errno(r, "Could not remove image: %s", bus_error_message(&error, r));
        }

        return 0;
}
Ejemplo n.º 29
0
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
	// No private area for this controller
	g->priv = 0;

	// Initialise the board interface
	init_board(g);

	// Hardware reset
	setpin_reset(g, TRUE);
	gfxSleepMilliseconds(20);
	setpin_reset(g, FALSE);
	gfxSleepMilliseconds(20);

	// Get the bus for the following initialisation commands
	acquire_bus(g);

  write_cmd(g, SSD1327_MAST_CODE); //Master code
  write_data(g, 0x00);
  write_cmd(g, SSD1327_SET_SLEEP_ON);  // set display off

  write_cmd(g, SSD1327_SET_REMAP);
  write_data(g, 0x52); 
  write_cmd(g, SSD1327_SET_DISPLAY_START);
  write_data(g, 0x00);
  write_cmd(g, SSD1327_SET_DISPLAY_OFFSET);
  write_data(g, 0x20);
  write_cmd(g, SSD1327_SET_DISPLAY_MODE_RESET);

  write_cmd(g, SSD1327_SET_MUX_RATIO);
  write_data(g, 0x5F);
  write_cmd(g, SSD1327_SET_FUNCTION_SELECT);
  write_data(g, 0x01);
  write_cmd(g, SSD1327_SET_CONTRAST);
  write_data(g, 0x5F);
  write_cmd(g, SSD1327_USE_LINEAR_GREY);

  write_cmd(g, SSD1327_SET_PHASE_LENGTH);
  write_data(g, 0x31);
  write_cmd(g, SSD1327_CLOCKDIV_OSCFREQ);
  write_data(g, 0x41);
  write_cmd(g, SSD1327_DISPLAY_ENHANCEMENT);
  write_data(g, 0xB5);
  write_cmd(g, SSD1327_SET_SECOND_PRECHARGE);
  write_data(g, 0x04);
  write_cmd(g, SSD1327_SET_PRECHARGE_VOLTAGE);
  write_data(g, 0x05);
  write_cmd(g, SSD1327_SET_VCOMH);
  write_data(g, 0x07);
  write_cmd(g, SSD1327_SET_FUNCTION_SELECT_B);
  write_data(g, 0x02);

//i2c restart
  write_cmd(g, SSD1327_MAST_CODE); //Master code
  write_data(g, 0x00);
  write_cmd(g, SSD1327_SET_COLUMN_ADDRESS); //Master code
  write_data(g, 0x00); //COLUMN START
  write_data(g, 0x3F); //COLUMN END
  write_cmd(g, SSD1327_SET_ROW_ADDRESS); //Master code
  write_data(g, 0x00); //ROW START
  write_data(g, 0x7F); //ROW END

  write_cmd(g, SSD1327_MAST_CODE); //Master code
  write_data(g, 0x40);

	uint16_t i = 0;
	for (i = 0; i < 128*128; i++)
  {
    write_data(g, 0);
  }

	release_bus(g);

    // Finish Init
    post_init_board(g);

 	// Release the bus
//	release_bus(g);

	/* Turn on the back-light */
	set_backlight(g, GDISP_INITIAL_BACKLIGHT);

	/* Initialise the GDISP structure */
	g->g.Width = GDISP_SCREEN_WIDTH;
	g->g.Height = GDISP_SCREEN_HEIGHT;
	g->g.Orientation = GDISP_ROTATE_0;
	g->g.Powermode = powerOn;
	g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
	g->g.Contrast = GDISP_INITIAL_CONTRAST;
	return TRUE;
}
Ejemplo n.º 30
0
//	#error "SSD1327 - Hardware control is not supported yet"
LLDSPEC void gdisp_lld_control(GDisplay *g) {
  switch(g->p.x) {
  case GDISP_CONTROL_POWER:
    if (g->g.Powermode == (powermode_t)g->p.ptr)
      return;
    switch((powermode_t)g->p.ptr) {
    case powerOff:
      acquire_bus(g);
      write_cmd(g, SSD1327_SET_DISPLAY_MODE_ALL_OFF);
      release_bus();
      break;
    case powerSleep:
    case powerDeepSleep:
      acquire_bus(g);
      write_cmd(g, SSD1327_SET_SLEEP_ON);
      release_bus(g);
      break;
    case powerOn:
      acquire_bus(g);
      write_cmd(g, SSD1327_SET_SLEEP_OFF);
      write_cmd(g, SSD1327_SET_DISPLAY_MODE_ALL_ON);
      release_bus(g);
      break;
    default:
      return;
    }
    g->g.Powermode = (powermode_t)g->p.ptr;
    return;

  case GDISP_CONTROL_ORIENTATION:
    if (g->g.Orientation == (orientation_t)g->p.ptr)
      return;
    switch((orientation_t)g->p.ptr) {
    case GDISP_ROTATE_0: // correct
      acquire_bus(g);
      write_reg(g, SSD1327_SET_REMAP, (0b01<<6) | (1<<5) | (1<<4) | (1<<2) | 0b00);
      // bits:
      // [0] : address increment (0: horizontal, 1: vertical, reset 0)
      // [1] : column remap (0: 0..127, 1: 127..0, reset 0)
      // [2] : color remap (0: A->B->C, 1: C->B->A, reset 0)
      // [3] : reserved
      // [4] : column scan direction (0: top->down, 1: bottom->up, reset 0)
      // [5] : odd/even split COM (0: disable, 1: enable, reset 1)
      // [6..7] : color depth (00,01: 65k, 10: 262k, 11: 262k format 2)
      write_cmd(g, SSD1327_WRITE_RAM);
      g->g.Height = GDISP_SCREEN_HEIGHT;
      g->g.Width = GDISP_SCREEN_WIDTH;
      release_bus(g);
      break;
    case GDISP_ROTATE_90:
      acquire_bus(g);
      write_reg(g, SSD1327_SET_REMAP, (0b01<<6) | (1<<5) | (1<<4) | (1<<2) | 0b10);
      write_cmd(g, SSD1327_WRITE_RAM);
      g->g.Height = GDISP_SCREEN_WIDTH;
      g->g.Width = GDISP_SCREEN_HEIGHT;
      release_bus(g);
      break;
    case GDISP_ROTATE_180:
      acquire_bus(g);
      write_reg(g, SSD1327_SET_REMAP, (0b01<<6) | (1<<5) | (0<<4) | (1<<2) | 0b00);
      write_reg(g, SSD1327_SET_REMAP, 0b01100110);
      write_cmd(g, SSD1327_WRITE_RAM);
      g->g.Height = GDISP_SCREEN_HEIGHT;
      g->g.Width = GDISP_SCREEN_WIDTH;
      release_bus(g);
      break;
    case GDISP_ROTATE_270:
      acquire_bus(g);
      write_reg(g, SSD1327_SET_REMAP, (0b01<<6) | (1<<5) | (0<<4) | (1<<2) | 0b01);
      write_cmd(g, SSD1327_WRITE_RAM);
      g->g.Height = GDISP_SCREEN_WIDTH;
      g->g.Width = GDISP_SCREEN_HEIGHT;
      release_bus(g);
      break;
    default:
      return;
    }
    g->g.Orientation = (orientation_t)g->p.ptr;
    return;

  case GDISP_CONTROL_BACKLIGHT:
      if ((unsigned)g->p.ptr > 100)
        g->p.ptr = (void *)100;
      set_backlight(g, (unsigned)g->p.ptr);
      g->g.Backlight = (unsigned)g->p.ptr;
      return;

  //case GDISP_CONTROL_CONTRAST:
      default:
          return;
  }
}