Trammell Hudson avatar Trammell Hudson committed b49c121 Draft

Improve asteroids font and add a text-console version

Comments (0)

Files changed (4)

 
 
 # Target file name (without extension).
-TARGET = scopeclock
+TARGET ?= scopeclock
 
 
 # List C source files here. (C dependencies are automatically generated.)
  
 const PROGMEM asteroids_char_t asteroids_font[] = {
 	['0' - 0x20] = { P(0,0), P(8,0), P(8,12), P(0,12), P(0,0), P(8,12), LAST },
-	['1' - 0x20] = { P(4,0), P(4,12), LAST },
+	['1' - 0x20] = { P(4,0), P(4,12), P(3,10), LAST },
 	['2' - 0x20] = { P(0,12), P(8,12), P(8,7), P(0,5), P(0,0), P(8,0), LAST },
 	['3' - 0x20] = { P(0,12), P(8,12), P(8,0), P(0,0), UP, P(0,6), P(8,6), LAST },
 	['4' - 0x20] = { P(0,12), P(0,6), P(8,6), UP, P(8,12), P(8,0), LAST },
-	['5' - 0x20] = { P(0,0), P(8,0), P(8,5), P(0,6), P(0,12), P(8,12), LAST },
+	['5' - 0x20] = { P(0,0), P(8,0), P(8,6), P(0,7), P(0,12), P(8,12), LAST },
 	['6' - 0x20] = { P(0,12), P(0,0), P(8,0), P(8,5), P(0,7), LAST },
 	['7' - 0x20] = { P(0,12), P(8,12), P(8,6), P(4,0), LAST },
 	['8' - 0x20] = { P(0,0), P(8,0), P(8,12), P(0,12), P(0,0), UP, P(0,6), P(8,6), },
 	['9' - 0x20] = { P(8,0), P(8,12), P(0,12), P(0,7), P(8,5), LAST },
+	[' ' - 0x20] = { LAST },
+	['.' - 0x20] = { P(3,0), P(4,0), LAST },
+	[',' - 0x20] = { P(2,0), P(4,2), LAST },
+	['-' - 0x20] = { P(2,6), P(6,6), LAST },
+	['+' - 0x20] = { P(1,6), P(7,6), UP, P(4,9), P(4,3), LAST },
+	['!' - 0x20] = { P(4,0), P(3,2), P(5,2), P(4,0), UP, P(4,4), P(4,12), LAST },
+	['#' - 0x20] = { P(2,4), P(2,8), P(6,8), P(6,4), P(2,4), LAST },
+	['^' - 0x20] = { P(2,6), P(4,12), P(6,6), LAST },
+	['=' - 0x20] = { P(1,4), P(7,4), UP, P(1,8), P(7,8), LAST },
+	['*' - 0x20] = { P(0,0), P(4,12), P(8,0), P(0,8), P(8,8), P(0,0), LAST },
+	['_' - 0x20] = { P(0,0), P(8,0), LAST },
+	['/' - 0x20] = { P(0,0), P(8,12), LAST },
+	['\\' - 0x20] = { P(0,12), P(8,0), LAST },
+	['@' - 0x20] = { P(8,4), P(4,0), P(0,4), P(0,8), P(4,12), P(8,8), P(4,4), P(3,6) },
+	['$' - 0x20] = { P(6,2), P(2,6), P(6,10), UP, P(4,12), P(4,0), LAST },
+	['&' - 0x20] = { P(8,0), P(4,12), P(8,8), P(0,4), P(4,0), P(8,4), LAST },
+	['[' - 0x20] = { P(6,0), P(2,0), P(2,12), P(6,12), LAST },
+	[']' - 0x20] = { P(2,0), P(6,0), P(6,12), P(2,12), LAST },
+	['(' - 0x20] = { P(6,0), P(2,4), P(2,8), P(6,12), LAST },
+	[')' - 0x20] = { P(2,0), P(6,4), P(6,8), P(2,12), LAST },
+	['{' - 0x20] = { P(6,0), P(4,2), P(4,10), P(6,12), UP, P(2,6), P(4,6), LAST },
+	['}' - 0x20] = { P(4,0), P(6,2), P(6,10), P(4,12), UP, P(6,6), P(8,6), LAST },
+	['%' - 0x20] = { P(0,0), P(8,12), UP, P(2,10), P(2,8), UP, P(6,4), P(6,2) },
+	['<' - 0x20] = { P(6,0), P(2,6), P(6,12), LAST },
+	['>' - 0x20] = { P(2,0), P(6,6), P(2,12), LAST },
+	['|' - 0x20] = { P(4,0), P(4,5), UP, P(4,6), P(4,12), LAST },
+	[':' - 0x20] = { P(4,9), P(4,7), UP, P(4,5), P(4,3), LAST },
+	[';' - 0x20] = { P(4,9), P(4,7), UP, P(4,5), P(1,2), LAST },
+	['"' - 0x20] = { P(2,10), P(2,6), UP, P(6,10), P(6,6), LAST },
+	['\'' - 0x20] = { P(2,6), P(6,10), LAST },
+	['`' - 0x20] = { P(2,10), P(6,6), LAST },
+	['~' - 0x20] = { P(0,4), P(2,8), P(6,4), P(8,8), LAST },
+	['?' - 0x20] = { P(0,8), P(4,12), P(8,8), P(4,4), UP, P(4,1), P(4,0), LAST },
 	['A' - 0x20] = { P(0,0), P(0,8), P(4,12), P(8,8), P(8,0), UP, P(0,4), P(8,4) },
 	['B' - 0x20] = { P(0,0), P(0,12), P(4,12), P(8,8), P(6,6), P(8,4), P(4,0), P(0,0) },
 	['C' - 0x20] = { P(8,0), P(0,0), P(0,12), P(8,12), LAST },
+/**
+ * \file Display "text" on the vector scope
+ *
+ */
+
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include <avr/interrupt.h>
+#include <stdint.h>
+#include <string.h>
+#include <util/delay.h>
+#include "usb_serial.h"
+#include "bits.h"
+#include "sin_table.h"
+#include "vector.h"
+#include "clock.h"
+
+
+
+
+void send_str(const char *s);
+uint8_t recv_str(char *buf, uint8_t size);
+void parse_and_execute_command(const char *buf, uint8_t num);
+
+static uint8_t
+hexdigit(
+	uint8_t x
+)
+{
+	x &= 0xF;
+	if (x < 0xA)
+		return x + '0' - 0x0;
+	else
+		return x + 'A' - 0xA;
+}
+
+
+static uint8_t
+printable(
+	uint8_t x
+)
+{
+	if ('A' <= x && x <= 'Z')
+		return 1;
+	if ('a' <= x && x <= 'z')
+		return 1;
+	if ('0' <= x && x <= '9')
+		return 1;
+	if (x == ' ')
+		return 1;
+
+	return 0;
+}
+
+
+#define MAX_ROWS 8
+#define MAX_COLS 12
+
+static char text[MAX_ROWS][MAX_COLS] = {
+	{ "" },
+	{ "Future crew" },
+	{ "Version 1.0" },
+	{ "Incept date" },
+	{ "1945-05-27" },
+/*
+	{ "0123456789-=" },
+	{ "~!@#$%^&*\\|_" },
+	{ "+`[]{}()<>/?" },
+*/
+};
+
+
+static void
+draw_text(void)
+{
+	uint8_t y = 256-32;
+	for (uint8_t row = 0 ; row < MAX_ROWS ; row++)
+	{
+		uint8_t x = 0;
+		for (uint8_t col = 0 ; col < MAX_COLS ; col++)
+		{
+			x += draw_char_med(x, y, text[row][col]);
+		}
+
+		y -= 32;
+	}
+}
+
+
+int main(void)
+{
+	// set for 16 MHz clock
+#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
+	CPU_PRESCALE(0);
+
+	// Disable the ADC
+	ADMUX = 0;
+
+	// initialize the USB, and then wait for the host
+	// to set configuration.  If the Teensy is powered
+	// without a PC connected to the USB port, this 
+	// will wait forever.
+	usb_init();
+	while (!usb_configured()) /* wait */ ;
+	_delay_ms(1000);
+
+	// wait for the user to run their terminal emulator program
+	// which sets DTR to indicate it is ready to receive.
+	while (!(usb_serial_get_control() & USB_SERIAL_DTR))
+		continue;
+
+	// discard anything that was received prior.  Sometimes the
+	// operating system or other software will send a modem
+	// "AT command", which can still be buffered.
+	usb_serial_flush_input();
+
+	DDRB = 0xFF;
+	DDRD = 0xFF;
+	PORTB = 128;
+	PORTD = 0;
+
+	clock_init();
+
+	uint8_t col = 0;
+
+	while (1)
+	{
+		draw_text();
+		int c = usb_serial_getchar();
+		if (c == -1)
+			continue;
+
+		if (c == '\f')
+		{
+			col = 0;
+			memset(text, '\0', sizeof(text));
+			continue;
+		}
+
+		if (col >= MAX_COLS || c == '\n')
+		{
+			memmove(&text[0], &text[1], (MAX_ROWS-1)*sizeof(text[0]));
+			memset(text[MAX_ROWS-1], '\0', sizeof(text[0]));
+			col = 0;
+		}
+
+		if (c < ' ')
+			continue;
+
+		text[MAX_ROWS-1][col++] = c;
+	}
+}
 	uint8_t oy = y;
 	uint8_t pen_down = 0;
 
+	if (c < 0x20)
+		return 0;
+
 #ifdef CONFIG_HERSHEY
 	const hershey_char_t * p = &hershey_simplex[c - 0x20];
 	const uint8_t count = pgm_read_byte(&p->count);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.