VLCB
Loading...
Searching...
No Matches
Parameters.h
Go to the documentation of this file.
1// Copyright (C) Sven Rosvall (sven@rosvall.ie)
2// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0/
5
6#pragma once
7
8#include <Arduino.h> // for definition of byte datatype
9
10#include <vlcbdefs.hpp> // MERG Controller constants
11
12namespace VLCB
13{
14
16{
17public:
18 explicit Parameters()
19 {
20 params[PAR_NUM] = 20; // 0 num params = 20
21 params[PAR_MANU] = MANU_MERG; // 1 manf = MERG, 165
22 params[PAR_EVTNUM] = 0; // 4 num events
23 params[PAR_EVNUM] = 0; // 5 num evs per event
24 params[PAR_NVNUM] = 0; // 6 num NVs
25 params[PAR_FLAGS] = 0;
26 params[PAR_BUSTYPE] = PB_CAN; // CAN implementation of Controller
27 params[PAR_LOAD] = 0x00;
28 params[PAR_LOAD+1] = 0x00;
29 params[PAR_LOAD+2] = 0x00;
30 params[PAR_LOAD+3] = 0x00;
31 initProcessorParams();
32 }
33
34 void setVersion(char major, char minor, char beta)
35 {
36 params[PAR_MAJVER] = major; // 7 code major version
37 params[PAR_MINVER] = minor; // 2 code minor version
38 params[PAR_BETA] = beta; // 20 code beta version
39 }
40
41 void setManufacturer(byte id)
42 {
43 params[PAR_MANU] = id;
44 }
45
46 void setModuleId(byte id)
47 {
48 params[PAR_MTYP] = id; // 3 module id
49 }
50
51 void setFlags(byte flags)
52 {
53 params[PAR_FLAGS] = flags; // 8 flags - FLiM, consumer/producer
54 }
55
56 // Optional: use this to override processor info that is set by default.
57 void setProcessor(byte manufacturer, byte id, char const * name)
58 {
59 params[PAR_CPUID] = id; // 9 processor id
60 params[PAR_CPUMAN] = manufacturer; // 19 processor manufacturer
61 memcpy(params + PAR_CPUMID, name, 4); // 15-18 processor version
62 }
63
64 unsigned char getParam(VlcbParams p) const
65 {
66 return params[p];
67 }
68
69 unsigned char * getParams() const
70 {
71 return params;
72 }
73
74 unsigned char * getParams()
75 {
76 return params;
77 }
78
79private:
80 // Initializes processor specific parameters based on pre-defined macros in Arduino IDE.
81 static void initProcessorParams();
82
83 // Memory for the params is allocated on global memory and handed over to Controller.updateParamFlags().
84 static unsigned char params[21];
85};
86
87}
unsigned char * getParams() const
Definition Parameters.h:69
void setProcessor(byte manufacturer, byte id, char const *name)
Definition Parameters.h:57
void setModuleId(byte id)
Definition Parameters.h:46
void setFlags(byte flags)
Definition Parameters.h:51
Parameters()
Definition Parameters.h:18
void setVersion(char major, char minor, char beta)
Definition Parameters.h:34
void setManufacturer(byte id)
Definition Parameters.h:41
unsigned char * getParams()
Definition Parameters.h:74
unsigned char getParam(VlcbParams p) const
Definition Parameters.h:64
Definition AbstractEventTeachingService.cpp:13
VlcbParams
Definition vlcbdefs.hpp:507
@ PAR_BUSTYPE
Definition vlcbdefs.hpp:524
@ PAR_BETA
Definition vlcbdefs.hpp:528
@ PAR_CPUID
Definition vlcbdefs.hpp:523
@ PAR_MANU
Definition vlcbdefs.hpp:515
@ PAR_CPUMID
Definition vlcbdefs.hpp:526
@ PAR_FLAGS
Definition vlcbdefs.hpp:522
@ PAR_MINVER
Definition vlcbdefs.hpp:516
@ PAR_EVTNUM
Definition vlcbdefs.hpp:518
@ PAR_NVNUM
Definition vlcbdefs.hpp:520
@ PAR_CPUMAN
Definition vlcbdefs.hpp:527
@ PAR_EVNUM
Definition vlcbdefs.hpp:519
@ PAR_MTYP
Definition vlcbdefs.hpp:517
@ PAR_MAJVER
Definition vlcbdefs.hpp:521
@ PAR_LOAD
Definition vlcbdefs.hpp:525
@ PAR_NUM
Definition vlcbdefs.hpp:514
@ MANU_MERG
Definition vlcbdefs.hpp:21
@ PB_CAN
Definition vlcbdefs.hpp:591