/*
 * Copyright 2011 - 2013 NTB University of Applied Sciences in Technology
 * Buchs, Switzerland, http://www.ntb.ch/inf
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.deepjava.runtime.zynq7000.test;

import java.io.PrintStream;
import org.deepjava.runtime.arm32.Task;
import org.deepjava.runtime.zynq7000.driver.UART;
import org.deepjava.runtime.zynq7000.driver.XADC;

/* CHANGES:
 * 28.04.2020 NTB/UG	creation
 */

/**
 * Demo application for the TCRT1000 driver.
 * The application reads periodically the values of four sensors
 * and print them every second to the UART1.
 */
public class XADCTest extends Task {
	
	/* (non-Javadoc)
	 * @see org.deepjava.runtime.arm32.Task#action()
	 */
	public void action() {
//		for(int i = 0; i < 4; i++) {
//			System.out.print(sense.read(i));
//			System.out.print('\t');
//		}
		System.out.print(XADC.read(0));
		System.out.print('\t');
		System.out.print(XADC.read(1));
		System.out.print('\t');
		System.out.print(XADC.read(2));
		System.out.print('\t');
		System.out.println(XADC.read(3));
	}
	
	static {
		UART uart = UART.getInstance(UART.pUART1);
		uart.start(115200, (short)0, (short)8);
		System.out = new PrintStream(uart.out);
		System.err = System.out;
		System.out.println("XADC test");
		
		// Initialize TCRT1000 driver for 4 sensors and start reading values
		
		// Create and install demo task
		Task t = new XADCTest();
		t.period = 1000;
		Task.install(t);
	}
}


@@ -1247,15 +1247,14 @@
 ) %7B%0A
-//
 %09%09for
+ 
 (int
@@ -1275,18 +1275,16 @@
  i++) %7B%0A
-//
 %09%09%09Syste
@@ -1299,153 +1299,24 @@
 int(
-sense.read(i));%0A//%09%09%09System.out.print('%5Ct');%0A//%09%09%7D%0A%09%09System.out.print(XADC.read(0));%0A%09%09System.out.print('%5Ct');%0A%09%09System.out.print(XADC.read(1
+XADC.read(i
 ));%0A
+%09
 %09%09Sy
@@ -1343,65 +1343,9 @@
 ;%0A%09%09
-System.out.print(XADC.read(2));%0A%09%09System.out.print('%5Ct');
+%7D
 %0A%09%09S
@@ -1366,20 +1366,8 @@
 tln(
-XADC.read(3)
 );%0A%09
@@ -1536,16 +1536,16 @@
 em.out;%0A
+
 %09%09System
@@ -1578,82 +1578,8 @@
 %0A%09%09%0A
-%09%09// Initialize TCRT1000 driver for 4 sensors and start reading values%0A%09%09%0A
 %09%09//

Improve example