1 #ifndef LIBRARIES_SENSORS_H 2 #define LIBRARIES_SENSORS_H 3 4 /* 5 sensors.library include (V51) 6 7 Copyright © 2010-2012 The MorphOS Development Team, Jacek Piszczek, All Rights Reserved. 8 9 Contact devenv@morphos-team.net if you would like to create custom sensors - to coordinate 10 the tagbase for you to use. 11 */ 12 13 #ifndef EXEC_TYPES_H 14 # include <exec/types.h> 15 #endif 16 17 #ifndef EXEC_PORTS_H 18 # include <exec/ports.h> 19 #endif 20 21 #ifndef UTILITY_TAGITEM_H 22 # include <utility/tagitem.h> 23 #endif 24 25 /* A notification message is sent to all clients that requested to be notified 26 ** whenever attributes of the sensor change. All fields are valid until the 27 ** message is replied */ 28 29 struct SensorsNotificationMessage 30 { 31 struct Message Msg; 32 33 /* Pointer to the Sensor device that triggered the notification message */ 34 APTR Sensor; 35 36 /* The UserData set by the client when registering a notification */ 37 APTR UserData; 38 39 /* A taglist containing the changed attributes and their new values */ 40 struct TagItem *Notifications; 41 }; 42 43 #define SENSORS_Dummy (TAG_USER + 0x200000) 44 45 /* Do note that the getter function assumes that the size of the var to write to is 46 ** sizeof (ULONG) (in case of DOUBLE *, sizeof (APTR) and the stored value must be a 47 ** valid address to a DOUBLE variable). So, for BOOL or UBYTE you still need to give it 48 ** a pointer to an ULONG! 49 ** All STRING variables are UTF-8 encoded. 50 */ 51 52 /* SensorType */ 53 #define SENSORS_Type (SENSORS_Dummy + 1) 54 55 /* SensorClass defines a type of sensor class. The classes are used 56 ** to group sensors by kind and to make searching for them easier. 57 ** SensorClass_System is *reserved* for MorphOS internal sensors. */ 58 #define SENSORS_Class (SENSORS_Dummy + 7) 59 60 /* Determines the parent sensor in child<>parent hierarchy of sensors. 61 ** Each top level sensor may have an unlimited (constrained by memory) 62 ** amount of child sensors. A child sensor may have child sensors 63 ** of its own. 64 ** 65 ** NOTE: when you obtain a parent sensor via GetSensorAttr, the parent 66 ** pointer sensor will remain valid as long as the item you've called 67 ** GetSensorAttr on stays valid. 68 */ 69 #define SENSORS_Parent (SENSORS_Dummy + 8) 70 71 /* BOOL, allows to hide a sensor (prevents it from appearing in the 72 ** lists generated by ObtainSensorsList). This is useful when 73 ** constructing a multi-child sensor to ensure nobody gets an 74 ** incomplete parent sensor. */ 75 #define SENSORS_Private (SENSORS_Dummy + 9) 76 77 /* BOOL, TRUE if this sensor has child sensors. Only supported in 78 ** GetSensorAttr */ 79 #define SENSORS_HasChildSensors (SENSORS_Dummy + 10) 80 81 /* SensorPlacement */ 82 #define SENSORS_SensorPlacement (SENSORS_Dummy + 2) 83 84 /* Extra data related to SensorPlacement, may be a core number, etc */ 85 #define SENSORS_SensorPlacementData (SENSORS_Dummy + 3) 86 87 /* Expected reading update time in ms */ 88 #define SENSORS_UpdateFrequency (SENSORS_Dummy + 4) 89 90 /* Attributes control */ 91 92 /* With regular sensor attributes, only the owner of the sensor (as 93 ** in, the caller of AddSensor) is allowed to set sensor values. In 94 ** some cases though, the owner may like to expose some attributes 95 ** to be setable by clients. In that case the owner must set the 96 ** AllowSetAttr attribute and register a notification on the attr. 97 ** Must be present *before* each value tag in AddSensor. */ 98 #define SENSORS_AllowSetAttr (SENSORS_Dummy + 11) 99 100 /* Use this to force notifications sent even if the attribute's 101 ** value did not change. 102 ** Must be present *before* each value tag in AddSensor if you wish 103 ** to set it. */ 104 #define SENSORS_NotifyAlways (SENSORS_Dummy + 12) 105 106 /* Must be present *before* each value tag in AddSensor if you wish 107 ** to add a DOUBLE data type tag. Otherwise ULONG/BOOL is assumed. 108 ** If set to TRUE, the data will be treated as a DOUBLE. If FALSE or 109 ** not present, the data will be treated as an ULONG/BOOL. */ 110 #define SENSORS_DataIsDOUBLE (SENSORS_Dummy + 5) 111 112 /* Must be present *before* each value tag in AddSensor if you wish 113 ** to add a STRING data type tag. Otherwise ULONG/BOOL is assumed. 114 ** The strings are assumed to be in UTF-8 format, NULL terminated. */ 115 #define SENSORS_DataIsSTRING (SENSORS_Dummy + 6) 116 117 118 119 /* System sensor attributes */ 120 121 /* DOUBLE *, sensor reading in Celsius */ 122 #define SENSORS_Temperature_Temperature (SENSORS_Dummy + 100) 123 124 /* DOUBLE *, sensor reading in Fahrenheit */ 125 #define SENSORS_Temperature_TemperatureF (SENSORS_Dummy + 101) 126 127 /* DOUBLE *, maximum allowed value in Celsius */ 128 #define SENSORS_Temperature_Max (SENSORS_Dummy + 102) 129 130 /* DOUBLE *, minimum allowed value in Celsius */ 131 #define SENSORS_Temperature_Min (SENSORS_Dummy + 103) 132 133 /* DOUBLE *, overheat alert temperature */ 134 #define SENSORS_Temperature_Alert (SENSORS_Dummy + 104) 135 136 /* DOUBLE *, temperature at which the alert is cancelled */ 137 #define SENSORS_Temperature_AlertCancel (SENSORS_Dummy + 105) 138 139 140 /* ULONG, battery capacity in mAh */ 141 #define SENSORS_Battery_Capacity (SENSORS_Dummy + 200) 142 143 /* ULONG, maximum capacity in mAh */ 144 #define SENSORS_Battery_MaxCapacity (SENSORS_Dummy + 201) 145 146 /* ULONG, charge cycle count */ 147 #define SENSORS_Battery_CycleCount (SENSORS_Dummy + 202) 148 149 /* BOOL, TRUE if the battery is charging */ 150 #define SENSORS_Battery_Charging (SENSORS_Dummy + 203) 151 152 /* ULONG, battery voltage in mV */ 153 #define SENSORS_Battery_Voltage (SENSORS_Dummy + 204) 154 155 /* BOOL, if FALSE means the machine has a battery slot, but there's no battery in it */ 156 #define SENSORS_Battery_Present (SENSORS_Dummy + 205) 157 158 /* ULONG, battery current in mA, positive value when charging, negative when discharging */ 159 #define SENSORS_Battery_Current (SENSORS_Dummy + 206) 160 161 /* BOOL, if turns to TRUE, it means the battery might be fault */ 162 #define SENSORS_Battery_Faulty (SENSORS_Dummy + 207) 163 164 /* ULONG, battery charge OR discharge time remaining in seconds (avg) */ 165 #define SENSORS_Battery_Remaining (SENSORS_Dummy + 208) 166 #define SENSORS_Battery_Remaining_Calculating 0xFFFFFFFF 167 #define SENSORS_Battery_Remaining_Charged 0xFFFFFFFE 168 169 /* BOOL, set to TRUE on low battery alert */ 170 #define SENSORS_Battery_LowBatteryAlert (SENSORS_Dummy + 209) 171 172 173 /* DOUBLE, ambient light reading (0.0 - 1.0) */ 174 #define SENSORS_AmbientLight_Level (SENSORS_Dummy + 300) 175 176 177 /* BOOL, TRUE if the lid is open */ 178 #define SENSORS_Lid_Open (SENSORS_Dummy + 400) 179 180 181 /* BOOL, TRUE when AC power is connected */ 182 #define SENSORS_ACPower_PluggedIn (SENSORS_Dummy + 500) 183 184 185 /* UBYTE, Fan speed - PWM cycle. Some fans may define speed in PWM duty 186 ** cycle, others might report RPM */ 187 #define SENSORS_Fan_Speed (SENSORS_Dummy + 600) 188 189 /* ULONG, Fan speed - RPM */ 190 #define SENSORS_Fan_RPM (SENSORS_Dummy + 601) 191 192 /* ULONG, Max fan RPM */ 193 #define SENSORS_Fan_RPM_Max (SENSORS_Dummy + 602) 194 195 /* ULONG, Minimum fan RPM */ 196 #define SENSORS_Fan_RPM_Min (SENSORS_Dummy + 603) 197 198 /* BeginSensorNotify special attributes */ 199 200 /* UserData will be placed in SensorsNotificationMessage */ 201 #define SENSORS_Notification_UserData (SENSORS_Dummy + 1000) 202 203 /* struct MsgPort *, Determines the port to send notifications to */ 204 #define SENSORS_Notification_Destination (SENSORS_Dummy + 1001) 205 206 /* BOOL, if TRUE, adding a notification will result in the value 207 ** being sent to the client immediately */ 208 #define SENSORS_Notification_SendInitialValue (SENSORS_Dummy + 1002) 209 210 /* BOOL, if TRUE, it means our sensor was removed */ 211 #define SENSORS_Notification_Removed (SENSORS_Dummy + 1003) 212 213 /* BOOL, if TRUE, it means the list of sensors matching a given 214 ** class has changed. When using this tag, it is assumed that you call 215 ** StartSensorNotify with a NULL pointer. */ 216 #define SENSORS_Notification_ClassListChanged (SENSORS_Dummy + 1004) 217 218 219 220 typedef enum 221 { 222 SensorType_Unknown = -1, 223 SensorType_Temperature = 0, 224 SensorType_Battery = 1, 225 SensorType_AmbientLight = 2, 226 SensorType_Lid = 3, 227 SensorType_ACPower = 4, 228 SensorType_Fan = 5, 229 230 SensorType_NumTypes 231 } SensorType; 232 233 typedef enum 234 { 235 SensorClass_All = -1, 236 SensorClass_System = 0, 237 SensorClass_Custom = 1, 238 SensorClass_HID = 2, 239 240 SensorClass_NumClasses 241 } SensorClass; 242 243 typedef enum 244 { 245 SensorPlacement_Other = -1, 246 SensorPlacement_Processor = 0, 247 SensorPlacement_NorthBridge = 1, 248 SensorPlacement_Battery = 2, 249 SensorPlacement_Trackpad = 3, 250 SensorPlacement_Keyboard = 4, 251 SensorPlacement_PowerSupply = 5, 252 SensorPlacement_Lid = 6, 253 SensorPlacement_Enclosure = 7, 254 SensorPlacement_EnclosureLeft = 8, 255 SensorPlacement_EnclosureRight = 9, 256 SensorPlacement_EnclosureBottom = 10, 257 SensorPlacement_EnclosureBottomLeft = 11, 258 SensorPlacement_EnclosureBottomRight = 12, 259 SensorPlacement_EnclosureTop = 13, 260 SensorPlacement_EnclosureTopLeft = 14, 261 SensorPlacement_EnclosureTopRight = 15, 262 SensorPlacement_SouthBridge = 16, 263 SensorPlacement_HardDrive = 17, 264 SensorPlacement_GPU = 18, 265 SensorPlacement_AmbientAir = 19, 266 SensorPlacement_AmbientGPU = 20, 267 SensorPlacement_AmbientNorthBridge = 21, 268 SensorPlacement_ODD = 22, 269 SensorPlacement_IncomingAir = 23, 270 SensorPlacement_BackSide = 24, 271 SensorPlacement_KodiakDiode = 25, 272 SensorPlacement_Tunnel = 26, 273 SensorPlacement_TunnelHeatSink = 27, 274 SensorPlacement_MLBInletAmbient = 28, 275 SensorPlacement_DriveBay = 29, 276 SensorPlacement_Mainboard = 30, 277 SensorPlacement_PCIeSwitch = 31, 278 279 SensorPlacement_NumPlacements 280 } SensorPlacement; 281 282 #endif /* LIBRARIES_SENSORS_H */ 283