Skip to content

Commit

Permalink
rename UID to prevent mix ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Reichhard committed Aug 30, 2021
1 parent 65ed69a commit 6035cd3
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion include/tf_hat_zero.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "brick_hat_zero.h"
#include "errors.h"

#define UID "V7o" // Change XXYYZZ to the UID of your HAT Zero Brick
#define UID_ZERO "V7o" // Change XXYYZZ to the UID of your HAT Zero Brick

extern void check(int rc, const char* msg);

Expand Down
2 changes: 1 addition & 1 deletion include/tf_ind_analog_in_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "hal_common.h"
#include "bricklet_industrial_dual_analog_in_v2.h"

#define UID "Sfw" // Change XYZ to the UID of your Industrial Dual Analog In Bricklet 2.0
#define UID_ANALOG_IN "Sfw" // Change XYZ to the UID of your Industrial Dual Analog In Bricklet 2.0

extern void check(int rc, const char* msg);
/*
Expand Down
2 changes: 1 addition & 1 deletion include/tf_ind_analog_out_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "hal_common.h"
#include "bricklet_industrial_analog_out_v2.h"

#define UID "XYZ" // Change XYZ to the UID of your Industrial Analog Out Bricklet 2.0
#define UID_ANALOG_OUT "XYZ" // Change XYZ to the UID of your Industrial Analog Out Bricklet 2.0

extern void check(int rc, const char* msg);

Expand Down
2 changes: 1 addition & 1 deletion include/tf_ind_ptc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "hal_common.h"
#include "bricklet_industrial_ptc.h"

#define UID "TMC" // Change XYZ to the UID of your PTC Bricklet 2.0
#define UID_PTC "TMC" // Change XYZ to the UID of your PTC Bricklet 2.0

extern void check(int rc, const char* msg);
/*
Expand Down
2 changes: 1 addition & 1 deletion include/tf_thermocouple.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "hal_common.h"
#include "bricklet_thermocouple_v2.h"

#define UID "RJH" // Change XYZ to the UID of your Thermocouple Bricklet 2.0
#define UID_THERMOCOUPLE "RJH" // Change XYZ to the UID of your Thermocouple Bricklet 2.0

extern void check(int rc, const char* msg);

Expand Down
23 changes: 4 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
TF_HalContext hal;

void check(int e_code, const char *c) {
if (e_code == TF_E_OK) {
return;
if (e_code != TF_E_OK) {
tf_hal_printf("Failed to %s: %s (error code %d)\n", c, tf_hal_strerror(e_code), e_code);
}

tf_hal_printf("Failed to %s: %s (error code %d)\n", c, tf_hal_strerror(e_code), e_code);
}
/*
// Callback function for temperature callback
Expand All @@ -33,19 +31,11 @@ void temperature_handler(TF_ThermocoupleV2 *device, int32_t temperature,
// TODO: Why i cannot forward declare these functions in tf_hat_zero.h / tf_thermocouple.h ?

extern "C" void hat_zero_setup(TF_HalContext *hal);
extern "C" void hat_zero_loop(TF_HalContext *hal);

extern "C" void thermocouple_setup(TF_HalContext *hal);
extern "C" void thermocouple_loop(TF_HalContext *hal);

extern "C" void ptc_setup(TF_HalContext *hal);
extern "C" void ptc_loop(TF_HalContext *hal);

extern "C" void analog_in_setup(TF_HalContext *hal);
extern "C" void analog_in_loop(TF_HalContext *hal);

extern "C" void analog_out_setup(TF_HalContext *hal);
extern "C" void analog_out_loop(TF_HalContext *hal);


void setup() {
// put your setup code here, to run once:
Expand All @@ -64,15 +54,10 @@ void setup() {

void loop() {
// put your main code here, to run repeatedly:
hat_zero_loop(&hal);
thermocouple_loop(&hal);
ptc_loop(&hal);
analog_in_loop(&hal);
//analog_out_loop(&hal); //bricklet not shipped until now..

//getDeviceInfo();
//createTraffic();

// Poll for callbacks
//tf_hal_callback_tick(&hal, 0);
tf_hal_callback_tick(&hal, 0);
}
2 changes: 1 addition & 1 deletion src/tf_hat_zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void check(int e_code, const char *c) {

void hat_zero_setup(TF_HalContext *hal) {
// Create device object
check(tf_hat_zero_create(&hz, UID, hal), "create device object");
check(tf_hat_zero_create(&hz, UID_ZERO, hal), "create device object");

// Get current voltage
uint16_t voltage;
Expand Down
2 changes: 1 addition & 1 deletion src/tf_ind_analog_in_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static TF_IndustrialDualAnalogInV2 idai;

void analog_in_setup(TF_HalContext *hal) {
// Create device object
check(tf_industrial_dual_analog_in_v2_create(&idai, UID, hal), "create device object");
check(tf_industrial_dual_analog_in_v2_create(&idai, UID_ANALOG_IN, hal), "create device object");

// Register voltage callback to function voltage_handler
tf_industrial_dual_analog_in_v2_register_voltage_callback(&idai,
Expand Down
2 changes: 1 addition & 1 deletion src/tf_ind_analog_out_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ static TF_IndustrialAnalogOutV2 iao;

void analog_out_setup(TF_HalContext *hal) {
// Create device object
check(tf_industrial_analog_out_v2_create(&iao, UID, hal), "create device object");
check(tf_industrial_analog_out_v2_create(&iao, UID_ANALOG_OUT, hal), "create device object");

// Set output current to 4.5mA
check(tf_industrial_analog_out_v2_set_current(&iao, 4500), "call set_current");
Expand Down
2 changes: 1 addition & 1 deletion src/tf_ind_ptc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static TF_IndustrialPTC ptc;

void ptc_setup(TF_HalContext *hal) {
// Create device object
check(tf_industrial_ptc_create(&ptc, UID, hal), "create device object");
check(tf_industrial_ptc_create(&ptc, UID_PTC, hal), "create device object");

// Register temperature callback to function temperature_handler
tf_industrial_ptc_register_temperature_callback(&ptc,
Expand Down
2 changes: 1 addition & 1 deletion src/tf_thermocouple.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static TF_ThermocoupleV2 t;

void thermocouple_setup(TF_HalContext *hal) {
// Create device object
check(tf_thermocouple_v2_create(&t, UID, hal), "create device object");
check(tf_thermocouple_v2_create(&t, UID_THERMOCOUPLE, hal), "create device object");

// Register temperature callback to function temperature_handler
tf_thermocouple_v2_register_temperature_callback(&t,
Expand Down

0 comments on commit 6035cd3

Please sign in to comment.