Pão de Queijo Development Board. This repo has all libraries from pqdb shield.

Dependents:   pqdb_demo

Pão de Queijo development board is a shield for add-on on any arduino compatible board.

/media/uploads/rmaalmeida/compatibilidade_branco.png

This project presents the libraries to control the board peripherals using mbed framework. The libraries works as interfaces to keep the main code compatible with the examples from the book "Programação de sistemas embarcados". The peripherals on the board are presented on the folowing picture

/media/uploads/rmaalmeida/pqdb_perifericos.png

The main objective of the project is to develop a low cost, easy to assemble board with a group of peripheral that allows one to start learning embedded systems. The board was routed on one side copper PCB to make easier to buid it yourself.

/media/uploads/rmaalmeida/pqdb_fenolite_-_cortada.png

The source code for Arduino boards (wiring) can be found on: https://github.com/projetopqdb/PQDB-Arduino

The source code for freedom frdm KL05 board (using direct register access) can be found on: https://github.com/projetopqdb/PQDB-KL05Z

The source code from the board schematics and layout can be found on: https://github.com/projetopqdb/PQDB-Hardware

Revision:
6:3fb450ba1e95
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/console.cpp	Tue Oct 03 01:27:24 2017 +0000
@@ -0,0 +1,96 @@
+#include "lcd.h"
+
+#define LCD_COLS 16
+#define LCD_LINES 2
+#define BUFF_LINES 4
+
+//mais um pra guardar o '\0' no fim de cada linha
+#define BUFF_COLS (LCD_COLS+1)
+
+char buffer[BUFF_LINES][BUFF_COLS];
+int line;
+int col;
+
+void consoleInit() {
+	int i, j;
+	lcdInit();
+	for (i = 0; i < BUFF_LINES; i++) {
+		for (j = 0; j < BUFF_COLS; j++) {
+			buffer[i][j] = '\0';
+		}
+	}
+	line = (BUFF_LINES - LCD_LINES);
+	col = 0;
+}
+
+void newLine(void) {
+	int l;
+	int c ;
+	//sobe cada linha do buffer em uma posição
+	for (l = 1; l < BUFF_LINES; l++) {
+		for (c = 0; c < BUFF_COLS; c++) {
+			buffer[l - 1][c] = buffer[l][c];
+		}
+	}
+	//limpa a última linha
+	for (l = 0; l < BUFF_COLS; l++) {
+		buffer[BUFF_LINES - 1][l] = '\0';
+	}
+}
+
+void consoleUpdate(void) {
+	int i, j;
+	lcdCommand(0x01);
+	for (i = 0; i < LCD_LINES; i++) {
+		lcdPosition(i,0);
+		for (j = 0; j < BUFF_COLS; j++) {
+			if ((buffer[line + i][j] == '\0')) {
+				break;
+			} else {
+				lcdChar(buffer[line + i][j]);
+			}
+		}
+	}
+}
+
+void consolePrint(char* vet) {
+	char i, j;
+	int currentPos = 0;
+	//enquanto a string não terminar continua processando
+	while (vet[currentPos] != '\0') {
+		//se chegou uma nova linha termina a atual e passa pra próxima
+		if (vet[currentPos] == '\n') {
+			buffer[BUFF_LINES - 1][col] = '\0';
+			col = 0;
+			newLine();
+		} else {
+			//se chegou uma letra normal armazena no buffer
+			buffer[BUFF_LINES - 1][col] = vet[currentPos];
+			col++;
+			//se encheu a linha, passa para próxima
+			//(-1 por causa do espaço para o '\0')
+			if (col >= (BUFF_COLS - 1)) {
+				buffer[BUFF_LINES - 1][BUFF_COLS - 1] = '\0';
+				col = 0;
+				newLine();
+			}
+		}
+		currentPos++;
+	}
+	//armazena '\0' na última posição
+	buffer[BUFF_LINES - 1][col] = vet[currentPos];
+}
+
+//muda a posição da linha que deve ser exibida
+void consoleMoveLine(int relativeMove) {
+	if (relativeMove < 0) {
+		if (line > 0) {
+			line--;
+		}
+	}
+	if (relativeMove > 0) {
+		if (line < BUFF_LINES - LCD_LINES) {
+			line++;
+		}
+	}
+}