Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions tests/test-grovelcd-cursor-manual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (c) 2016, Intel Corporation.

console.log("test cursor position");

var grove_lcd = require("grove_lcd");

var glcd = grove_lcd.init();

var displays = [
grove_lcd.GLCD_DS_DISPLAY_ON,
grove_lcd.GLCD_DS_DISPLAY_OFF,
grove_lcd.GLCD_DS_CURSOR_ON,
grove_lcd.GLCD_DS_CURSOR_OFF,
grove_lcd.GLCD_DS_BLINK_ON,
grove_lcd.GLCD_DS_BLINK_OFF
];

var cursorFlag = true;
var cursorCol = -1;
var cursorRow = 0;
var cursorCount = 0;

glcd.setCursorPos(0, 0);
glcd.setDisplayState(displays[0] | displays[2]);
glcd.print("cursor position");

var cycleTimer = setInterval(function () {
if (cursorCount === 0) {
glcd.setCursorPos(6, 1);
glcd.print("BLINK");
glcd.setDisplayState(displays[0] | displays[2] | displays[4]);

console.log("set cursor as 'on' and blink");
}

if (cursorCount === 64) {
glcd.clear();
glcd.setCursorPos(6, 1);
glcd.print("_END_");
glcd.setDisplayState(displays[0] | displays[3]);

console.log("Testing completed");

clearInterval(cycleTimer);
}

if (cursorFlag) {
cursorCol++;
} else {
cursorCol--;
}

if (cursorCount <= 31) {
if (cursorCol === 16) {
cursorFlag = false;
cursorCol = 15;
cursorRow = 1;
}
}

if (cursorCount === 32) {
cursorFlag = true;
glcd.setCursorPos(5, 1);
glcd.print("NOBLINK");
cursorCol = 0;
cursorRow = 1;
glcd.setDisplayState(displays[0] | displays[2]);

console.log("set cursor as 'on' and no blink");
}

if (32 <= cursorCount && cursorCount <= 63) {
if (cursorCol === 16) {
cursorFlag = false;
cursorCol = 15;
cursorRow = 0;
}
}

if (cursorCount <= 63) {
glcd.setCursorPos(cursorCol, cursorRow);

console.log("setCursorPos(col, row): expected result "
+ cursorCol + ", " + cursorRow);
}

cursorCount++;
}, 1000);
76 changes: 76 additions & 0 deletions tests/test-grovelcd-ds-manual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) 2016, Intel Corporation.

console.log("test GroveLCD display");

var grove_lcd = require("grove_lcd");

var glcd = grove_lcd.init();

var funs = [
grove_lcd.GLCD_FS_ROWS_1,
grove_lcd.GLCD_FS_ROWS_2,
grove_lcd.GLCD_FS_8BIT_MODE,
grove_lcd.GLCD_FS_DOT_SIZE_BIG,
grove_lcd.GLCD_FS_DOT_SIZE_LITTLE
];

var index = [
[0, 2, "ROW1, 8BIT"],
[1, 2, "ROW2, 8BIT"],
[2, 3, "8BIT, BIG"],
[2, 4, "8BIT, LIT"],
[0, 3, "ROW1, BIG"],
[0, 4, "ROW1, LIT"],
[1, 3, "ROW2, BIG"],
[1, 4, "ROW2, LIT"],
[0, 2, 3, "ROW1, 8BIT, BIG"],
[0, 2, 4, "ROW1, 8BIT, LIT"],
[1, 2, 3, "ROW2, 8BIT, BIG"],
[1, 2, 4, "ROW2, 8BIT, LIT"]
];

glcd.setColor(50, 50, 50);

var count = 0;
var funcConfig;

var timer = setInterval(function () {
if (count === index.length) {
glcd.clear();
glcd.setCursorPos(6, 1);
glcd.print("_END_");

console.log("Testing completed");

clearInterval(timer);
}

if (index[count].length === 3) {
funcConfig = funs[index[count][0]]
| funs[index[count][1]];
glcd.setFunction(funcConfig);

glcd.clear();
glcd.setCursorPos(0, 0);
glcd.print(index[count][2]);

console.log("setFunction(row, mode, dot): expected result "
+ index[count][2]);
}

if (index[count].length === 4) {
funcConfig = funs[index[count][0]]
| funs[index[count][1]]
| funs[index[count][2]];
glcd.setFunction(funcConfig);

glcd.clear();
glcd.setCursorPos(0, 0);
glcd.print(index[count][3]);

console.log("setFunction(row, mode, dot): expected result "
+ index[count][3]);
}

count++;
}, 5000);
119 changes: 119 additions & 0 deletions tests/test-grovelcd-rgb-manual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright (c) 2016, Intel Corporation.

console.log("test RGB color");

var grove_lcd = require("grove_lcd");

var glcd = grove_lcd.init();

var colorNum = [
[255, 0, 0],
[0, 255, 0],
[0, 0, 255],
[255, 255, 0],
[255, 0, 255],
[0, 255, 255],
[255, 255, 255]
];

var colorName = [
" red ",
"green ",
" blue ",
"yellow",
"purple",
" cyan ",
"white "
];

var displayConfig = grove_lcd.GLCD_DS_DISPLAY_ON
| grove_lcd.GLCD_DS_CURSOR_OFF;
glcd.setDisplayState(displayConfig);

glcd.setCursorPos(1, 0);
glcd.print("Color Gradient");

var flag = true;
var redFlag = colorNum[0][0];
var greenFlag = colorNum[0][1];
var blueFlag = colorNum[0][2];
var redNum = 0;
var greenNum = 0;
var blueNum = 0;
var colorCount = 0;
var count = 0;

var colorGradient = setInterval(function () {
glcd.setCursorPos(5, 1);
glcd.print(colorName[colorCount]);

if (count === 102) {
colorCount++;
count = 0;

if (colorCount === 7) {
glcd.clear();
glcd.setCursorPos(6, 1);
glcd.print("_END_");

console.log("Testing completed");

clearInterval(colorGradient);
}

redFlag = colorNum[colorCount][0];
greenFlag = colorNum[colorCount][1];
blueFlag = colorNum[colorCount][2];
}

if (count === 0) {
console.log("setColor(R, G, B): expected result "
+ redFlag + ", " + greenFlag + ", " + blueFlag);
console.log("color gradient: " + colorName[colorCount]);
}

if (redNum === 255 || greenNum === 255 || blueNum === 255) {
flag = false;
}

if (flag) {
if (redFlag > 0) {
redNum += 5;
}

if (greenFlag > 0) {
greenNum += 5;
}

if (blueFlag > 0) {
blueNum += 5;
}
} else {
if (redFlag > 0) {
redNum -= 5;

if (redNum === 0) {
flag = true;
}
}

if (greenFlag > 0) {
greenNum -= 5;

if (greenNum === 0) {
flag = true;
}
}

if (blueFlag > 0) {
blueNum -= 5;

if (blueNum === 0) {
flag = true;
}
}
}

glcd.setColor(redNum, greenNum, blueNum);
count++;
}, 100);