Browse Source

Some documentation work

Philipp Hinz 8 năm trước cách đây
mục cha
commit
460ec05282
4 tập tin đã thay đổi với 43 bổ sung28 xóa
  1. 2 2
      CoffeeCode/doxy.cfg
  2. 15 14
      CoffeeCode/hal.cpp
  3. 11 2
      CoffeeCode/spi.cpp
  4. 15 10
      CoffeeCode/stripe.cpp

+ 2 - 2
CoffeeCode/doxy.cfg

@@ -32,7 +32,7 @@ DOXYFILE_ENCODING      = UTF-8
 # title of most generated pages and in a few other places.
 # The default value is: My Project.
 
-PROJECT_NAME           = "Speedmanager"
+PROJECT_NAME           = "CoffeePi"
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
 # could be handy for archiving the generated documentation or if some version
@@ -44,7 +44,7 @@ PROJECT_NAME           = "Speedmanager"
 # for a project that appears at the top of each page and should give viewer a
 # quick idea about the purpose of the project. Keep the description short.
 
-PROJECT_BRIEF          = "CAN Speedmanager for Raspberry Pi"
+PROJECT_BRIEF          = "Coffee machine control for Raspberry Pi"
 
 # With the PROJECT_LOGO tag one can specify a logo or an icon that is included
 # in the documentation. The maximum height of the logo should not exceed 55

+ 15 - 14
CoffeeCode/hal.cpp

@@ -16,7 +16,7 @@
 
 int flowcnt = 0;
 
-/*
+/**
  * Initializes HAL
  */
 void halInit(void) {
@@ -59,7 +59,7 @@ void halInit(void) {
 	}
 }
 
-/*
+/**
  * Switches relais on
  * @param relais Relais ID
  */
@@ -67,7 +67,7 @@ void halRelaisOn(int relais) {
 	halRelaisSet(relais, LOW);
 }
 
-/*
+/**
  * Switches relais off
  * @param relais Relais ID
  */
@@ -75,7 +75,7 @@ void halRelaisOff(int relais) {
 	halRelaisSet(relais, HIGH);
 }
 
-/*
+/**
  * Switches relais to state
  * @param relais Relais ID
  * @param state LOW(0) or HIGH(1)
@@ -92,7 +92,7 @@ void halRelaisSet(int relais, int state) {
 	}
 }
 
-/*
+/**
  * Returns the state of the relais relais
  * Returns HIGH when Relais is ON
  * @param relais Relais ID
@@ -137,7 +137,7 @@ void halIntFlow(void) {
 	 flowcnt++;
 }
 
-/*
+/**
  * Method to handle toggle of the pressure control
  */
 void halIntPressure(void) {
@@ -149,7 +149,7 @@ void halIntPressure(void) {
 	}
 }
 
-/*
+/**
  * Method to handle toggle of the proximity sensor
  */
 void halIntProximity(void) {
@@ -161,21 +161,21 @@ void halIntProximity(void) {
 	}
 }
 
-/*
+/**
  * Returns total flow trough sensor in ml
  */
 float halGetFlow(void) {
 	return flowcnt*FLOW_ML_PULSE;
 }
 
-/*
+/**
  * Resets the Flow counter
  */
 void halResetFlow(void){
 	flowcnt = 0;
 }
 
-/*
+/**
  * Reads the status of the Pressure Control
  * @return 0 for closed Pressure Control(heating) and 1 for open
  */
@@ -187,7 +187,7 @@ bool halIsHeating(void) {
 	}
 }
 
-/*
+/**
  * Returns status of the proximity switch
  * @return 1 if the proximity switch is covered and 0 if uncovered
  */
@@ -200,7 +200,7 @@ bool halProxSensorCovered(void){
 	return true;
 }
 
-/*
+/**
  * Returns the value of the top button Int0 (low active)
  * @return LOW or HIGH
  */
@@ -208,7 +208,7 @@ int halGetInt0(void){
 	return digitalRead(INT0);
 }
 
-/*
+/**
  * Returns the value of the bottom button Int1 (low active)
  * @return LOW or HIGH
  */
@@ -216,8 +216,9 @@ int halGetInt1(void){
 	return digitalRead(INT1);
 }
 
-/*
+/**
  * send Signal to coffee thread
+ * @param val Integer value assigned to signal
  */
 void halSendSignal(int val){
 	sigval value = {0};

+ 11 - 2
CoffeeCode/spi.cpp

@@ -18,7 +18,7 @@
 #include "spi.h"
 
 /**
- * writes the data on the SPI bus and returns the reply
+ * Writes the data on the SPI bus and returns the reply
  * @param data byte to write to the bus
  * @return byte read from the bus
  */
@@ -33,7 +33,7 @@ uint8_t spi_readwrite(uint8_t data) {
 }
 
 /**
- * initializes the SPI bus
+ * Initializes the SPI bus
  */
 
 void spi_init(void) {
@@ -44,6 +44,10 @@ void spi_init(void) {
 	}
 }
 
+/**
+ * Initializes the shift register
+ */
+
 void shift_init(void) {
 	pinMode(SHIFT_G, OUTPUT);
 	pinMode(SHIFT_RCK, OUTPUT);
@@ -57,6 +61,11 @@ void shift_init(void) {
 	digitalWrite(SHIFT_SCLR, HIGH);
 }
 
+/**
+ * Sends a byte to the shift register
+ * @param data Data byte
+ */
+
 void shift_data(uint8_t data) {
 	spi_readwrite(data);
 	digitalWrite(SHIFT_RCK, HIGH);

+ 15 - 10
CoffeeCode/stripe.cpp

@@ -31,7 +31,7 @@ void *stripeTimerHandler(void *threadid) {
 	if (currentColor.red == effectColor.red
 			&& currentColor.green == effectColor.green
 			&& currentColor.blue == effectColor.blue) {
-		stripeSetRGB(0,0,0);
+		stripeSetRGB(0, 0, 0);
 	} else {
 		stripeSetColor(effectColor);
 	}
@@ -61,9 +61,11 @@ void *stripeThread(void *threadid) {
 		logger(V_NONE, LOG_ERRORC, "Simulating %d%% percent heating\n", tmp);
 		sleep(1);
 		if (inc) {
-			if (++tmp >= 100) inc = 0;
+			if (++tmp >= 100)
+				inc = 0;
 		} else {
-			if (--tmp <= 0) inc = 1;
+			if (--tmp <= 0)
+				inc = 1;
 		}
 	}
 
@@ -77,11 +79,11 @@ void stripeInit() {
 	i2cfd = wiringPiI2CSetup(I2C_ADDRESS_STRIPE);
 	if (i2cfd < 0) {
 		logger_error("Could not initialize i2c with device ID 0x%.2x (%s)\n",
-				I2C_ADDRESS_STRIPE, strerror(errno));
+		I2C_ADDRESS_STRIPE, strerror(errno));
 		pthread_exit(NULL);
 	}
 	logger(V_STRIPE, "Initialized i2c device on address 0x%.2x\n",
-			I2C_ADDRESS_STRIPE);
+	I2C_ADDRESS_STRIPE);
 	currentColor.red = 0;
 	currentColor.green = 0;
 	currentColor.blue = 0;
@@ -94,17 +96,19 @@ void stripeInit() {
  * Sends out command data to the stripe controller via i2c
  * @param len Length of the data array
  * @param *data Pointer to data array
+ * @return Number of failed bytes, 0 if successful
  */
 int stripeCommand(int len, char* data) {
 	int ret = 0;
 	int i = 0;
 	pthread_mutex_lock(&mutex);
 	for (i = 0; i < len; i++) {
-		ret += wiringPiI2CWriteReg8(i2cfd, i, data[i]);
+		ret -= wiringPiI2CWriteReg8(i2cfd, i, data[i]);
 	}
 	logger(V_STRIPE, "Wrote %d bytes to i2c device\n", len);
 	if (ret)
-		logger(V_NONE, LOG_WARN, "Failed to write %d of %d bytes on i2c device\n", ret, len);
+		logger(V_NONE, LOG_WARN,
+				"Failed to write %d of %d bytes on i2c device\n", ret, len);
 	pthread_mutex_unlock(&mutex);
 	return ret;
 }
@@ -255,13 +259,14 @@ void stripeEffectDisable(void) {
 void stripeEffectHeating(int percent) {
 	long red, blue;
 
-	if (percent > 100) percent = 100;
+	if (percent > 100)
+		percent = 100;
 
 	red = percent * 255;
-	blue = (100-percent) * 255;
+	blue = (100 - percent) * 255;
 
 	stripeSetTransient(TRANS_FAST);
-	stripeSetRGB(red/100,0,blue/100);
+	stripeSetRGB(red / 100, 0, blue / 100);
 }
 
 /**