From 51699171c289c5ff553ed0c9c75c5a108e164fff Mon Sep 17 00:00:00 2001
From: Clyne Sullivan <tullivan99@gmail.com>
Date: Tue, 6 Oct 2015 14:41:38 -0400
Subject: uploaded code

---
 src/Makefile    | 50 +++++++++++++++++++++++++++++++++++++++
 src/auto.c      | 52 +++++++++++++++++++++++++++++++++++++++++
 src/init.c      | 15 ++++++++++++
 src/opcontrol.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/robot.cpp   |  1 +
 src/robot.h     |  6 +++++
 6 files changed, 196 insertions(+)
 create mode 100644 src/Makefile
 create mode 100644 src/auto.c
 create mode 100644 src/init.c
 create mode 100644 src/opcontrol.c
 create mode 100644 src/robot.cpp
 create mode 100644 src/robot.h

(limited to 'src')

diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..865f1e7
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,50 @@
+# Makefile for compiling PROS projects
+
+# Path to project root (NO trailing slash!)
+ROOT=..
+# Binary output directory
+BINDIR=$(ROOT)/bin
+
+# Nothing below here needs to be modified by typical users
+
+# Include common aspects of this project
+-include $(ROOT)/common.mk
+
+ASMSRC:=$(wildcard *.$(ASMEXT))
+ASMOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(ASMSRC:.$(ASMEXT)=.o))
+HEADERS:=$(wildcard *.$(HEXT))
+### Special section for Cortex projects ###
+HEADERS_2:=$(wildcard ../include/*.$(HEXT))
+### End special section ###
+CSRC=$(wildcard *.$(CEXT))
+COBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CSRC:.$(CEXT)=.o))
+CPPSRC:=$(wildcard *.$(CPPEXT))
+CPPOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CPPSRC:.$(CPPEXT)=.o))
+OUT:=$(BINDIR)/$(OUTNAME)
+
+.PHONY: all
+
+# By default, compile program
+all: .
+
+# Compiles the program if anything is changed
+.: $(ASMOBJ) $(COBJ) $(CPPOBJ)
+	@touch .
+
+# Assembly source file management
+$(ASMOBJ): $(BINDIR)/%.o: %.$(ASMEXT)
+	@echo AS $<
+	@$(AS) $(AFLAGS) -o $@ $<
+
+### Special section for Cortex projects ###
+
+# Object management
+$(COBJ): $(BINDIR)/%.o: %.$(CEXT) $(HEADERS) $(HEADERS_2)
+	@echo CC $(INCLUDE) $<
+	@$(CC) $(INCLUDE) $(CFLAGS) -o $@ $<
+
+$(CPPOBJ): $(BINDIR)/%.o: %.$(CPPEXT) $(HEADERS) $(HEADERS_2)
+	@echo CPC $(INCLUDE) $<
+	@$(CPPCC) $(INCLUDE) $(CPPFLAGS) -o $@ $<
+
+### End special section ###
diff --git a/src/auto.c b/src/auto.c
new file mode 100644
index 0000000..9df57af
--- /dev/null
+++ b/src/auto.c
@@ -0,0 +1,52 @@
+/** @file auto.c
+ * @brief File for autonomous code
+ *
+ * This file should contain the user autonomous() function and any functions related to it.
+ *
+ * Copyright (c) 2011-2014, Purdue University ACM SIG BOTS.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Purdue University ACM SIG BOTS nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL PURDUE UNIVERSITY ACM SIG BOTS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Purdue Robotics OS contains FreeRTOS (http://www.freertos.org) whose source code may be
+ * obtained from http://sourceforge.net/projects/freertos/files/ or on request.
+ */
+
+#include "main.h"
+
+/*
+ * Runs the user autonomous code. This function will be started in its own task with the default
+ * priority and stack size whenever the robot is enabled via the Field Management System or the
+ * VEX Competition Switch in the autonomous mode. If the robot is disabled or communications is
+ * lost, the autonomous task will be stopped by the kernel. Re-enabling the robot will restart
+ * the task, not re-start it from where it left off.
+ *
+ * Code running in the autonomous task cannot access information from the VEX Joystick. However,
+ * the autonomous function can be invoked from another task if a VEX Competition Switch is not
+ * available, and it can access joystick information if called in this way.
+ *
+ * The autonomous task may exit, unlike operatorControl() which should never exit. If it does
+ * so, the robot will await a switch to another mode or disable/enable cycle.
+ */
+void autonomous() {
+}
diff --git a/src/init.c b/src/init.c
new file mode 100644
index 0000000..f3948f0
--- /dev/null
+++ b/src/init.c
@@ -0,0 +1,15 @@
+#include "main.h"
+
+Gyro gyro;
+unsigned int imeCount=0;
+
+void initializeIO(void){
+	pinMode(1,INPUT_ANALOG);
+}
+
+void initialize(void){
+	lcdInit(uart1);
+	lcdClear(uart1);
+	gyro=gyroInit(2,0);
+	imeCount=imeInitializeAll();
+}
diff --git a/src/opcontrol.c b/src/opcontrol.c
new file mode 100644
index 0000000..b2896a2
--- /dev/null
+++ b/src/opcontrol.c
@@ -0,0 +1,72 @@
+#include "main.h"
+
+#define NEAR_THRESH 0.05f
+
+enum MOTOR {
+	UNUSED = 0,
+	ROTATER,
+	DRIVEL,
+	DRIVER,
+	LIFT1,
+	LIFT2,
+	INTAKE,
+	UNUSED7,
+	UNUSED8,
+	UNUSED9,
+	UNUSED10
+};
+
+static unsigned char idx=0;
+static float intakeRotation=0;
+
+int nearDegree(float target){
+	if(intakeRotation<target-NEAR_THRESH)return  1;
+	if(intakeRotation>target+NEAR_THRESH)return -1;
+	else				    			 return  0;
+}
+
+void operatorControlLCD(void *param){
+	static int imeValue=0;
+	static float nearTarget=0;
+	while(1){
+		imeGet(idx,&imeValue);
+		intakeRotation=imeValue/1037.0f;
+		lcdPrint(uart1,1,"%u %d",imeCount,nearDegree(nearTarget));
+		lcdPrint(uart1,2,"%u %d",idx,imeValue);
+		if(joystickGetDigital(1,7,JOY_LEFT)){
+			if(idx)idx--;
+		}else if(joystickGetDigital(1,7,JOY_RIGHT)){
+			if(idx<imeCount-1)idx++;
+		}
+		if(joystickGetDigital(1,8,JOY_LEFT)){
+			nearTarget-=.25;
+		}else if(joystickGetDigital(1,8,JOY_RIGHT)){
+			nearTarget+=.25;
+		}
+		delay(300);
+	}
+}
+
+void operatorControl(void){
+	static char liftSpeed=0;
+	static char intakeSpeed=0;
+	taskCreate(operatorControlLCD,TASK_DEFAULT_STACK_SIZE,NULL,TASK_PRIORITY_DEFAULT);
+	while(1){
+		// Set drive motors
+		motorSet(DRIVEL, joystickGetAnalog(1,3));
+		motorSet(DRIVER,-joystickGetAnalog(1,2));
+		liftSpeed=-(joystickGetDigital(1,6,JOY_UP  )? 127:
+				    joystickGetDigital(1,6,JOY_DOWN)?-127:0);
+		motorSet(LIFT1,liftSpeed);
+		motorSet(LIFT2,liftSpeed);
+		intakeSpeed=-(joystickGetDigital(1,5,JOY_UP  )? 127:
+					  joystickGetDigital(1,5,JOY_DOWN)?-127:0);
+		motorSet(INTAKE,intakeSpeed);
+		motorSet(ROTATER,joystickGetAnalog(1,1));
+
+		// test motor
+		//motorSet(10,joystickGetDigital(1,7,JOY_UP)?127:0);
+
+		delay(20);
+	}
+}
diff --git a/src/robot.cpp b/src/robot.cpp
new file mode 100644
index 0000000..82c45cd
--- /dev/null
+++ b/src/robot.cpp
@@ -0,0 +1 @@
+#include <robot.h>
diff --git a/src/robot.h b/src/robot.h
new file mode 100644
index 0000000..f8887da
--- /dev/null
+++ b/src/robot.h
@@ -0,0 +1,6 @@
+#ifndef ROBOT_H_
+#define ROBOT_H_
+
+#include <API.h>
+
+#endif /* ROBOT_H_ */
-- 
cgit v1.2.3