ssd1351: Initial implementation

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu
2016-03-03 17:22:12 -08:00
parent 0b49cbab9b
commit 144937995c
11 changed files with 1216 additions and 8 deletions

View File

@ -10,7 +10,7 @@ macro(get_module_name example_name module_name)
elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
set (${module_name} "gas")
else()
set(${module_name} ${example_name})
set(${module_name} ${example_name})
endif()
endmacro()
@ -25,25 +25,25 @@ macro(add_custom_example example_bin example_src example_module_list)
if (MODULE_LIST)
list(FIND MODULE_LIST ${module} index)
if (${index} EQUAL -1)
set(found_all_modules FALSE)
set(found_all_modules FALSE)
endif()
endif()
endforeach()
if (found_all_modules)
add_executable (${example_bin} ${example_src})
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
foreach (module ${example_module_list})
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
include_directories (${module_dir})
if (${module} STREQUAL "lcd")
set(module "i2clcd")
set(module "i2clcd")
endif()
target_link_libraries (${example_bin} ${module})
target_link_libraries (${example_bin} ${module})
endforeach()
else()
MESSAGE(INFO " Ignored ${example_bin}")
set (example_bin "")
endif()
endif()
endmacro()
@ -56,13 +56,13 @@ macro(add_example example_name)
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
AND EXISTS ${module_dir}
AND IS_DIRECTORY ${module_dir})
AND IS_DIRECTORY ${module_dir})
add_custom_example(${example_bin} ${example_src} ${module_name})
if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
if (EXISTS ${grove_module_path})
include_directories(${grove_module_path})
target_link_libraries (${example_bin} ${example_name})
target_link_libraries (${example_bin} ${example_name})
endif()
endif()
else()
@ -239,6 +239,7 @@ add_example (hdxxvxta)
add_example (rhusb)
add_example (apds9930)
add_example (kxcjk1013)
add_example (ssd1351)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)

61
examples/c++/ssd1351.cxx Normal file
View File

@ -0,0 +1,61 @@
#include "mraa.hpp"
#include <iostream>
#include <unistd.h>
#include "ssd1351.h"
#define BLACK 0x0000
#define WHITE 0xFFFF
#define INTEL_BLUE 0x0BF8
int main(int argc, char **argv)
{
// Define colors (16-bit RGB on 5/6/5 bits)
int colors[] = {0x0000, 0x000F, 0x03E0, 0x03EF,
0x7800, 0x780F, 0x7BE0, 0xC618,
0x7BEF, 0x001F, 0x07E0, 0x07FF,
0xF800, 0xF81F, 0xFFE0, 0xFFFF};
//! [Interesting]
// Initialize display with pins
// oc = 0, dc = 1, r = 2, si = 11, cl = 13
upm::SSD1351* display = new upm::SSD1351(0, 1, 2);
// Test lines pixel by pixel
for(int i = 0; i < SSD1351HEIGHT; i++) {
for(int j = 0; j < SSD1351WIDTH; j++) {
display->drawPixel(i, j, colors[i/8]);
}
}
display->refresh();
sleep(5);
// Test rectangles
for(int i = 0; i < SSD1351HEIGHT/32; i++) {
for (int j = 0; j < SSD1351WIDTH/32; j++) {
display->fillRect(i * 32, j * 32, 32, 32, colors[i * 4 + j]);
}
}
display->refresh();
sleep(5);
// Test circles
display->fillScreen(0x2104);
for(int i = 0; i < SSD1351HEIGHT/32; i++) {
for (int j = 0; j < SSD1351WIDTH/32; j++) {
display->drawCircle(i * 32 + 15, j * 32 + 15, 15, colors[i * 4 + j]);
}
}
display->refresh();
sleep(5);
// Test Text
display->fillScreen(INTEL_BLUE);
display->setTextColor(WHITE, INTEL_BLUE);
display->setTextSize(4);
display->setCursor(7, 30);
display->print("Intel");
display->setCursor(5, 70);
display->print("IoTDK");
display->refresh();
//! [Interesting]
}