WARDuino icon indicating copy to clipboard operation
WARDuino copied to clipboard

Cardputer display

Open tolauwae opened this issue 3 months ago • 2 comments

Cardputer display hardware support

The M5stack cardputer built-in display can be controlled with the M5Cardputer library.

  • [x] This PR ports the display functions to WARDuino, needed for the Basic example.
  • [x] This includes a new random primitive for Arduino.

hardware: https://docs.m5stack.com/en/core/Cardputer library: https://docs.arduino.cc/libraries/m5cardputer/ example: https://github.com/m5stack/M5Cardputer/blob/master/examples/Basic/display/display.ino

tolauwae avatar Oct 28 '25 08:10 tolauwae

I might try to get the rectangle drawing working on zephyr, already did a small experiment to draw a rectangle using the display API on the esp32-wrover-kit.

Just for future reference once I work on it, this code can be used to draw the yellow rectangle:

void draw_rect(struct device *display_dev, int xpos, int ypos, int w, int h, uint64_t color) {
	struct display_buffer_descriptor new_buf_desc;
	new_buf_desc.width = w;
	new_buf_desc.height = h;
	new_buf_desc.buf_size = new_buf_desc.width * new_buf_desc.height;
	new_buf_desc.pitch = new_buf_desc.width;
	new_buf_desc.frame_incomplete = false;
	uint16_t* new_buf = malloc(sizeof(uint16_t) * new_buf_desc.buf_size); // 16 bit color
	for (int y = 0; y < new_buf_desc.height; y++) {
		for(int x = 0; x < new_buf_desc.width; x++) {
			new_buf[y * new_buf_desc.width + x] = color;
		}
	}
	display_write(display_dev, xpos, ypos, &new_buf_desc, new_buf);
	free(new_buf);
}
draw_rect(display_dev, 64, 32, 128, 64, 0b0000000000011111);
draw_rect(display_dev, 64, 96, 128, 64, 0b1111100000000000);
draw_rect(display_dev, 64, 160, 128, 64, 0b0000011111100000);
image

MaartenS11 avatar Oct 29 '25 10:10 MaartenS11

⚠️ Current sketches compiled with Arduino take up too much space. 1310832 out of 1310720 bytes. Temporarily removed some other primitives to fix this.

tolauwae avatar Oct 29 '25 12:10 tolauwae