Demonstrate numerous different methods of the PropWare::Utility class
cmake_minimum_required(VERSION 3.12)
project(Utility_Demo)
create_simple_executable(${PROJECT_NAME} Utility_Demo.cpp)
static void sampleCountBits ();
static void sampleTimeMeasurement ();
static void sampleFreeMemory ();
pwOut.
println(
"Hello! Let's explore some of PropWare's utility functions");
sampleCountBits();
sampleTimeMeasurement();
sampleFreeMemory();
return 0;
}
void sampleTimeMeasurement () {
unsigned int start =
CNT;
pwOut.
println(
"But how long does it take to send each of these messages?");
uint32_t timeInMicros = Utility::measure_time_interval(start);
pwOut.
printf(
"Well that previous message took precisely %u microseconds.\n", timeInMicros);
}
void sampleCountBits () {
int bits = 0x42;
pwOut.
printf(
"How many bits are set in 0x%02X?\n", bits);
pwOut.
printf(
"\tThe answer is... %u\n", Utility::count_bits(bits));
}
void sampleFreeMemory () {
pwOut.
printf(
"The largest contiguous block of free memory is %u bytes\n",
Utility::get_largest_free_block_size());
}