1 /* 2 * Author: Stefan Andritoiu <stefan.andritoiu (at) intel.com> 3 * Copyright (c) 2015 Intel Corporation. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining 6 * a copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sublicense, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be 14 * included in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 //NOT TESTED!!! 26 public class ST7735Sample { 27 28 static { 29 try { 30 System.loadLibrary("javaupm_st7735"); 31 } catch (UnsatisfiedLinkError e) { 32 System.err.println("error in loading native library"); 33 System.exit(-1); 34 } 35 } 36 37 public static void main(String[] args) throws InterruptedException { 38 // ! [Interesting] 39 upm_st7735.ST7735 lcd = new upm_st7735.ST7735((short) 7, (short) 4, (short) 9, (short) 8); 40 41 lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_RED); 42 lcd.refresh(); 43 44 lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_CYAN); 45 lcd.refresh(); 46 47 lcd.fillScreen(upm_st7735.javaupm_st7735Constants.ST7735_BLACK); 48 lcd.refresh(); 49 50 lcd.drawLine((short) 10, (short) 10, (short) 10, (short) 100, 51 upm_st7735.javaupm_st7735Constants.ST7735_MAGENTA); 52 lcd.drawLine((short) 20, (short) 20, (short) 10, (short) 100, 53 upm_st7735.javaupm_st7735Constants.ST7735_YELLOW); 54 lcd.drawLine((short) 30, (short) 30, (short) 50, (short) 100, 55 upm_st7735.javaupm_st7735Constants.ST7735_WHITE); 56 lcd.refresh(); 57 58 lcd.drawPixel((short) 20, (short) 20, upm_st7735.javaupm_st7735Constants.ST7735_GREEN); 59 lcd.refresh(); 60 61 lcd.drawTriangle((short) 50, (short) 50, (short) 80, (short) 80, (short) 60, (short) 90, 62 upm_st7735.javaupm_st7735Constants.ST7735_GREEN); 63 lcd.refresh(); 64 65 lcd.drawCircle((short) 100, (short) 110, (short) 10, 66 upm_st7735.javaupm_st7735Constants.ST7735_BLUE); 67 lcd.refresh(); 68 69 lcd.setTextWrap((short) 0); 70 71 lcd.setCursor((short) 0, (short) 30); 72 lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED, 73 upm_st7735.javaupm_st7735Constants.ST7735_RED); 74 lcd.setTextSize((short) 1); 75 lcd.print("Hello World!"); 76 77 lcd.setCursor((short) 10, (short) 50); 78 lcd.setTextColor(upm_st7735.javaupm_st7735Constants.ST7735_RED, 79 upm_st7735.javaupm_st7735Constants.ST7735_YELLOW); 80 lcd.setTextSize((short) 2); 81 lcd.print("BIG"); 82 83 lcd.refresh(); 84 // ! [Interesting] 85 } 86 }