Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Trigger.h « GCodes « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2683ffac040a3cdac95812a0ca08ebddef4ec8dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Trigger.h
 *
 *  Created on: 6 Jun 2019
 *      Author: David
 */

#ifndef SRC_GCODES_TRIGGER_H_
#define SRC_GCODES_TRIGGER_H_

#include "RepRapFirmware.h"
#include "Hardware/IoPorts.h"

typedef uint32_t TriggerNumbersBitmap;					// Bitmap of trigger numbers
typedef uint16_t TriggerInputStatesBitmap;				// Bitmap of input states
static_assert(MaxTriggers <= sizeof(TriggerNumbersBitmap) * CHAR_BIT, "need larger TriggerNumbersBitmap type");
static_assert(MaxPortsPerTrigger <= sizeof(TriggerInputStatesBitmap) * CHAR_BIT, "need larger TriggerInputStatesBitmap");

struct Trigger
{
	Trigger() noexcept;

	void Init() noexcept;

	// Return true if this trigger is unused, i.e. it doesn't watch any pins
	bool IsUnused() const noexcept;

	// Check whether this trigger is active and update the input states
	bool Check() noexcept;

	IoPort ports[MaxPortsPerTrigger];
	TriggerInputStatesBitmap inputStates;
	uint8_t condition;
};


#endif /* SRC_GCODES_TRIGGER_H_ */