Mercurial > public > ostc4
annotate Discovery/Inc/crcmodel.h @ 868:db92692c014f Evo_2_23
Introduce speed dependend coloring of depth:
The depth value in the will now be colored based on the current ascent speed. The color code matches the one of the bar graph which was already used for visualization of the ascent speed. To keep color code consistent the existing color selection functions have been merged to one common Gfx function (T3/T7 - bar graph and color text)
author | Ideenmodellierer |
---|---|
date | Mon, 12 Aug 2024 15:14:19 +0200 |
parents | 45b8f3c2acce |
children |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Inc/crcmodel.h | |
5 /// \brief Rocksoft CRC Model Algorithm | |
6 /// \author Ross Williams (ross@guest.adelaide.edu.au.) and Heinrichs Weikamp | |
7 /// \date 3 June 1993 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// This is the header (.h) file for the reference | |
12 /// implementation of the Rocksoft^tm Model CRC Algorithm. For more | |
13 /// information on the Rocksoft^tm Model CRC Algorithm, see the document | |
14 /// titled "A Painless Guide to CRC Error Detection Algorithms" by Ross | |
15 /// Williams (ross@guest.adelaide.edu.au.). This document is likely to be in | |
16 /// "ftp.adelaide.edu.au/pub/rocksoft". | |
17 /// | |
18 /// Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. | |
19 /// | |
20 /// $Id$ | |
21 /////////////////////////////////////////////////////////////////////////////// | |
22 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
23 /// | |
24 /// This program is free software: you can redistribute it and/or modify | |
25 /// it under the terms of the GNU General Public License as published by | |
26 /// the Free Software Foundation, either version 3 of the License, or | |
27 /// (at your option) any later version. | |
28 /// | |
29 /// This program is distributed in the hope that it will be useful, | |
30 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
31 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
32 /// GNU General Public License for more details. | |
33 /// | |
34 /// You should have received a copy of the GNU General Public License | |
35 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
36 ////////////////////////////////////////////////////////////////////////////// | |
37 | |
38 /******************************************************************************/ | |
39 /* Start of crcmodel.h */ | |
40 /******************************************************************************/ | |
41 /* */ | |
42 /* Author : Ross Williams (ross@guest.adelaide.edu.au.). */ | |
43 /* Date : 3 June 1993. */ | |
44 /* Status : Public domain. */ | |
45 /* */ | |
46 /* Description : This is the header (.h) file for the reference */ | |
47 /* implementation of the Rocksoft^tm Model CRC Algorithm. For more */ | |
48 /* information on the Rocksoft^tm Model CRC Algorithm, see the document */ | |
49 /* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */ | |
50 /* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */ | |
51 /* "ftp.adelaide.edu.au/pub/rocksoft". */ | |
52 /* */ | |
53 /* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */ | |
54 /* */ | |
55 /******************************************************************************/ | |
56 /* */ | |
57 /* How to Use This Package */ | |
58 /* ----------------------- */ | |
59 /* Step 1: Declare a variable of type cm_t. Declare another variable */ | |
60 /* (p_cm say) of type p_cm_t and initialize it to point to the first */ | |
61 /* variable (e.g. p_cm_t p_cm = &cm_t). */ | |
62 /* */ | |
63 /* Step 2: Assign values to the parameter fields of the structure. */ | |
64 /* If you don't know what to assign, see the document cited earlier. */ | |
65 /* For example: */ | |
66 /* p_cm->cm_width = 16; */ | |
67 /* p_cm->cm_poly = 0x8005L; */ | |
68 /* p_cm->cm_init = 0L; */ | |
69 /* p_cm->cm_refin = TRUE; */ | |
70 /* p_cm->cm_refot = TRUE; */ | |
71 /* p_cm->cm_xorot = 0L; */ | |
72 /* Note: Poly is specified without its top bit (18005 becomes 8005). */ | |
73 /* Note: Width is one bit less than the raw poly width. */ | |
74 /* */ | |
75 /* Step 3: Initialize the instance with a call cm_ini(p_cm); */ | |
76 /* */ | |
77 /* Step 4: Process zero or more message bytes by placing zero or more */ | |
78 /* successive calls to cm_nxt. Example: cm_nxt(p_cm,ch); */ | |
79 /* */ | |
80 /* Step 5: Extract the CRC value at any time by calling crc = cm_crc(p_cm); */ | |
81 /* If the CRC is a 16-bit value, it will be in the bottom 16 bits. */ | |
82 /* */ | |
83 /******************************************************************************/ | |
84 /* */ | |
85 /* Design Notes */ | |
86 /* ------------ */ | |
87 /* PORTABILITY: This package has been coded very conservatively so that */ | |
88 /* it will run on as many machines as possible. For example, all external */ | |
89 /* identifiers have been restricted to 6 characters and all internal ones to */ | |
90 /* 8 characters. The prefix cm (for Crc Model) is used as an attempt to avoid */ | |
91 /* namespace collisions. This package is endian independent. */ | |
92 /* */ | |
93 /* EFFICIENCY: This package (and its interface) is not designed for */ | |
94 /* speed. The purpose of this package is to act as a well-defined reference */ | |
95 /* model for the specification of CRC algorithms. If you want speed, cook up */ | |
96 /* a specific table-driven implementation as described in the document cited */ | |
97 /* above. This package is designed for validation only; if you have found or */ | |
98 /* implemented a CRC algorithm and wish to describe it as a set of parameters */ | |
99 /* to the Rocksoft^tm Model CRC Algorithm, your CRC algorithm implementation */ | |
100 /* should behave identically to this package under those parameters. */ | |
101 /* */ | |
102 /******************************************************************************/ | |
103 | |
104 #ifndef CRC_MODEL_H | |
105 #define CRC_MODEL_H | |
106 | |
107 /******************************************************************************/ | |
108 | |
109 /* The following definitions are extracted from my style header file which */ | |
110 /* would be cumbersome to distribute with this package. The DONE_STYLE is the */ | |
111 /* idempotence symbol used in my style header file. */ | |
112 | |
113 #ifndef DONE_STYLE | |
114 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
38
diff
changeset
|
115 #include <stdbool.h> |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
38
diff
changeset
|
116 |
38 | 117 typedef unsigned long ulong; |
118 typedef unsigned char * p_ubyte_; | |
119 | |
120 #ifndef TRUE | |
121 #define FALSE 0 | |
122 #define TRUE 1 | |
123 #endif | |
124 | |
125 /* Change to the second definition if you don't have prototypes. */ | |
126 #define P_(A) A | |
127 /* #define P_(A) () */ | |
128 | |
129 /* Uncomment this definition if you don't have void. */ | |
130 /* typedef int void; */ | |
131 | |
132 #endif | |
133 | |
134 /******************************************************************************/ | |
135 | |
136 /* CRC Model Abstract Type */ | |
137 /* ----------------------- */ | |
138 /* The following type stores the context of an executing instance of the */ | |
139 /* model algorithm. Most of the fields are model parameters which must be */ | |
140 /* set before the first initializing call to cm_ini. */ | |
141 typedef struct | |
142 { | |
143 int cm_width; /* Parameter: Width in bits [8,32]. */ | |
144 ulong cm_poly; /* Parameter: The algorithm's polynomial. */ | |
145 ulong cm_init; /* Parameter: Initial register value. */ | |
146 bool cm_refin; /* Parameter: Reflect input bytes? */ | |
147 bool cm_refot; /* Parameter: Reflect output CRC? */ | |
148 ulong cm_xorot; /* Parameter: XOR this to output CRC. */ | |
149 | |
150 ulong cm_reg; /* Context: Context during execution. */ | |
151 } cm_t; | |
152 typedef cm_t *p_cm_t; | |
153 | |
154 /******************************************************************************/ | |
155 | |
156 /* Functions That Implement The Model */ | |
157 /* ---------------------------------- */ | |
158 /* The following functions animate the cm_t abstraction. */ | |
159 | |
160 void cm_ini P_((p_cm_t p_cm)); | |
161 /* Initializes the argument CRC model instance. */ | |
162 /* All parameter fields must be set before calling this. */ | |
163 | |
164 void cm_nxt P_((p_cm_t p_cm,int ch)); | |
165 /* Processes a single message byte [0,255]. */ | |
166 | |
167 void cm_blk P_((p_cm_t p_cm,p_ubyte_ blk_adr,ulong blk_len)); | |
168 /* Processes a block of message bytes. */ | |
169 | |
170 ulong cm_crc P_((p_cm_t p_cm)); | |
171 /* Returns the CRC value for the message bytes processed so far. */ | |
172 | |
173 /******************************************************************************/ | |
174 | |
175 /* Functions For Table Calculation */ | |
176 /* ------------------------------- */ | |
177 /* The following function can be used to calculate a CRC lookup table. */ | |
178 /* It can also be used at run-time to create or check static tables. */ | |
179 | |
180 ulong cm_tab P_((p_cm_t p_cm,int index)); | |
181 /* Returns the i'th entry for the lookup table for the specified algorithm. */ | |
182 /* The function examines the fields cm_width, cm_poly, cm_refin, and the */ | |
183 /* argument table index in the range [0,255] and returns the table entry in */ | |
184 /* the bottom cm_width bytes of the return value. */ | |
185 | |
186 /******************************************************************************/ | |
187 | |
188 #endif // CRC_MODEL_H |