示例#1
0
void switchPage(page_type _page) {
  PTS("Switching from "); PT(page);
  PTS(", to "); PTL(_page);
  page = _page;
  lcd.clear();
  //Without this the page will stay empty for a while
  // forceLCDupdate = true; 
}
示例#2
0
void check_serial_cmd()
{
	while (Serial.available())
	{
		delay(1);
		static String command;
		char input = Serial.read();

		if (input == '\r')
		{

		} 
		else if (input == '\n')
		{
			if (command.equals(("size")))
			{
				PTS("Schedule size: ");
				PTL(node_size());
			} else if (command.equals(("mem"))) {
				PTLS("Reading");
				for (int i = 0; i < MAX_NODE; i++) {
					schedule s = node_get(i);
					PT(i); PTS(", ");
					PT(s.day); PTS(", ");
					PT(s.hour); PTS(", ");
					PT(s.minute); PTS(", ");
					PT(s.temperature); PTL();
				}
			} else if (command.equals(("RESET"))) {
				PTLS("Resetting Memory");
				node_RESET();
			}
			command = "";
		}
		else
		{
			command.concat(input);
		}

	}
}
示例#3
0
inline void page_modifyTime() {
  static int timeScaleIndex = 0;
  if (pre_page != MODIFY_TIME)
  {
    PTLS("Page Mod Time");
    pre_page = MODIFY_TIME;
    lcd.cursor();
  }
  lcd.setCursor(0,1);
  String str_time = getTimeString(); 
  lcd.print(str_time);

  if (timeScaleIndex == 0) lcd.setCursor(0,1);
  else if (timeScaleIndex == 1) lcd.setCursor(0,4);
  else if (timeScaleIndex == 2) lcd.setCursor(0,7);
    
  if (button_input == PLUS_UP || button_input == PLUS_HOLD)
  {
    long adjust = timeScale[timeScaleIndex];
    adjustTime(adjust);
    setSyncInterval(SCALE_HOUR);
  }
  else if (button_input == MINUS_UP || button_input == MINUS_HOLD)
  {
    long adjust = -timeScale[timeScaleIndex];
    adjustTime(adjust);
    setSyncInterval(SCALE_HOUR);
  }
  else if (button_input == SET_UP)
  {
    setSyncInterval( 3600 );
    switchPage(HOME);
  }
  else if (button_input == MODE_UP)
  {
    timeScaleIndex++;
    timeScaleIndex = timeScaleIndex % 3;
    PTS("Changed focus: "); PTL(timeScaleIndex);
  }
}
示例#4
0
static int
ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf,
			      struct sdr_record_common_sensor *sensor,
			      uint8_t sdr_record_type)
{
	int thresh_available = 1;
	struct ipmi_rs *rsp;
	struct sensor_reading *sr;

	sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3);

	if (sr == NULL) {
		return -1;
	}

	const char *thresh_status = ipmi_sdr_get_thresh_status(sr, "ns");

	/*
	 * Get sensor thresholds
	 */
	rsp = ipmi_sdr_get_sensor_thresholds(intf,
				sensor->keys.sensor_num, sensor->keys.owner_id,
				sensor->keys.lun, sensor->keys.channel);

	if ((rsp == NULL) || (rsp->ccode > 0) || (rsp->data_len == 0))
		thresh_available = 0;

	if (csv_output) {
		/* NOT IMPLEMENTED */
	} else {
		if (verbose == 0) {
			/* output format
			 *   id value units status thresholds....
			 */
			printf("%-16s ", sr->s_id);
			if (sr->s_reading_valid) {
				if (sr->s_has_analog_value)
					printf("| %-10.3f | %-10s | %-6s",
					       sr->s_a_val, sr->s_a_units, thresh_status);
				else
					printf("| 0x%-8x | %-10s | %-6s",
					       sr->s_reading, sr->s_a_units, thresh_status);
			} else {
				printf("| %-10s | %-10s | %-6s",
				       "na", sr->s_a_units, "na");
			}
			if (thresh_available && sr->full) {
#define PTS(bit, dataidx) {						\
	print_thresh_setting(sr->full, rsp->data[0] & (bit),  		\
	    rsp->data[(dataidx)], "| ", "%-10.3f", "0x-8x", "%-10s");	\
}
				PTS(LOWER_NON_RECOV_SPECIFIED,	3);
				PTS(LOWER_CRIT_SPECIFIED,	2);
				PTS(LOWER_NON_CRIT_SPECIFIED,	1);
				PTS(UPPER_NON_CRIT_SPECIFIED,	4);
				PTS(UPPER_CRIT_SPECIFIED,	5);
				PTS(UPPER_NON_RECOV_SPECIFIED,	6);
#undef PTS
			} else {
				printf
				    ("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
				     "na", "na", "na", "na", "na", "na");
			}

			printf("\n");
		} else {
			printf("Sensor ID              : %s (0x%x)\n",
			       sr->s_id, sensor->keys.sensor_num);

			printf(" Entity ID             : %d.%d\n",
			       sensor->entity.id, sensor->entity.instance);

			printf(" Sensor Type (Threshold)  : %s\n",
			       ipmi_sdr_get_sensor_type_desc(sensor->sensor.
							     type));

			printf(" Sensor Reading        : ");
			if (sr->s_reading_valid) {
				if (sr->full) {
					uint16_t raw_tol = __TO_TOL(sr->full->mtol);
					if (sr->s_has_analog_value) {
						double tol =
						    sdr_convert_sensor_tolerance(sr->full,
									       raw_tol);
						printf("%.*f (+/- %.*f) %s\n",
						       (sr->s_a_val == (int)
						       sr->s_a_val) ? 0 : 3,
						       sr->s_a_val,
						       (tol == (int) tol) ? 0 : 3, tol,
						       sr->s_a_units);
					} else {
						printf("0x%x (+/- 0x%x) %s\n",
						       sr->s_reading,
						       raw_tol,
						       sr->s_a_units);
					}
				} else {
					printf("0x%x %s\n", sr->s_reading,
					sr->s_a_units);
				}
				printf(" Status                : %s\n", thresh_status);

				if (thresh_available) {
					if (sr->full) {
#define PTS(bit, dataidx, str) { 			\
print_thresh_setting(sr->full, rsp->data[0] & (bit),	\
		     rsp->data[(dataidx)], 		\
		    (str), "%.3f\n", "0x%x\n", "%s\n"); \
}

						PTS(LOWER_NON_RECOV_SPECIFIED,	3, " Lower Non-Recoverable : ");
						PTS(LOWER_CRIT_SPECIFIED,	2, " Lower Critical        : ");
						PTS(LOWER_NON_CRIT_SPECIFIED,	1, " Lower Non-Critical    : ");
						PTS(UPPER_NON_CRIT_SPECIFIED,	4, " Upper Non-Critical    : ");
						PTS(UPPER_CRIT_SPECIFIED,	5, " Upper Critical        : ");
						PTS(UPPER_NON_RECOV_SPECIFIED,	6, " Upper Non-Recoverable : ");
#undef PTS

					}
					ipmi_sdr_print_sensor_hysteresis(sensor, sr->full,
						sr->full ?  sr->full->threshold.hysteresis.positive :
						sr->compact->threshold.hysteresis.positive,
						"Positive Hysteresis");

					ipmi_sdr_print_sensor_hysteresis(sensor, sr->full,
						sr->full ?  sr->full->threshold.hysteresis.negative :
						sr->compact->threshold.hysteresis.negative,
						"Negative Hysteresis");
				} else {
					printf(" Sensor Threshold Settings not available\n");
				}
			} else {
			  printf(" Unable to read sensor: Device Not Present\n\n");
			}

			ipmi_sdr_print_sensor_event_status(intf,
							   sensor->keys.
							   sensor_num,
							   sensor->sensor.type,
							   sensor->event_type,
							   ANALOG_SENSOR,
							   sensor->keys.owner_id,
							   sensor->keys.lun,
							   sensor->keys.channel);
			ipmi_sdr_print_sensor_event_enable(intf,
							   sensor->keys.
							   sensor_num,
							   sensor->sensor.type,
							   sensor->event_type,
							   ANALOG_SENSOR,
							   sensor->keys.owner_id,
							   sensor->keys.lun,
							   sensor->keys.channel);

			printf("\n");
		}
	}

	return (sr->s_reading_valid ? 0 : -1 );
}